derived colors (mkiv)
Hi, there is currently no bookkeeping ('name-->id') for derived colors in mkiv; i.e. \definecolor[foo] [black] does not register 'foo'. \csname(ca:foo)\endcsname is the only way to access the color id. While this in no problem in TeX code, using this in lua is not very handy. I tried ugly stuff like c_id = format("\\csname(ca:%s)\\endcsname",c) but when I compare 'c_id' with the id of black, the values '1' and 1 (id of black) differ when compared. Mhhhh. I think that the best way to handle derived colors properly is to add their name to the attributes list too. It's only a small patch and it shouldn't do any harm. Best wishes, Peter
Peter Rolf schrieb:
Hi,
there is currently no bookkeeping ('name-->id') for derived colors in mkiv; i.e. \definecolor[foo] [black] does not register 'foo'.
\csname(ca:foo)\endcsname
is the only way to access the color id. While this in no problem in TeX code, using this in lua is not very handy. I tried ugly stuff like
c_id = format("\\csname(ca:%s)\\endcsname",c)
but when I compare 'c_id' with the id of black, the values '1' and 1 (id of black) differ when compared. Mhhhh.
I think that the best way to handle derived colors properly is to add their name to the attributes list too. It's only a small patch and it shouldn't do any harm.
.... I forgot to test the existense of a 'name' :( hopefully now foolprooved. if name then local stra = attributes.list[attributes.numbers['color']][str] if stra then attributes.list[attributes.numbers['color']][name] = stra -- inherit color id else attributes.list[attributes.numbers['color']][name] = attributes.list[attributes.numbers['color']][black] end end
Best wishes, Peter
------------------------------------------------------------------------
_______________________________________________ dev-context mailing list dev-context@ntg.nl http://www.ntg.nl/mailman/listinfo/dev-context
Peter Rolf wrote:
Peter Rolf schrieb:
Hi,
there is currently no bookkeeping ('name-->id') for derived colors in mkiv; i.e. \definecolor[foo] [black] does not register 'foo'.
\csname(ca:foo)\endcsname
is the only way to access the color id. While this in no problem in TeX code, using this in lua is not very handy. I tried ugly stuff like
c_id = format("\\csname(ca:%s)\\endcsname",c)
but when I compare 'c_id' with the id of black, the values '1' and 1 (id of black) differ when compared. Mhhhh.
I think that the best way to handle derived colors properly is to add their name to the attributes list too. It's only a small patch and it shouldn't do any harm.
..... I forgot to test the existense of a 'name' :( hopefully now foolprooved.
if name then local stra = attributes.list[attributes.numbers['color']][str] if stra then attributes.list[attributes.numbers['color']][name] = stra -- inherit color id else attributes.list[attributes.numbers['color']][name] = attributes.list[attributes.numbers['color']][black] end end
btw ... \setupcolors[state=start] \starttext \definecolor[foo][black] {\red red {\foo black} red} \definecolor[black][green] {\red red {\foo black} red} \stoptext you cannot freeze foo to black ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Peter Rolf wrote:
Hi,
there is currently no bookkeeping ('name-->id') for derived colors in mkiv; i.e. \definecolor[foo] [black] does not register 'foo'.
\csname(ca:foo)\endcsname
is the only way to access the color id. While this in no problem in TeX code, using this in lua is not very handy. I tried ugly stuff like
c_id = format("\\csname(ca:%s)\\endcsname",c)
hm, why do you want to use that number? th ecurrent implementation is not frozen so depending on it at the lua level can be dangerous
but when I compare 'c_id' with the id of black, the values '1' and 1 (id of black) differ when compared. Mhhhh.
I think that the best way to handle derived colors properly is to add their name to the attributes list too. It's only a small patch and it shouldn't do any harm.
i'm not sure about this yet; also, if something like happens it sould happen in the clone/inherit functions and not only in this one spot (there are more places and there's also transparency) so, what exactly do you need the number for ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (2)
-
Hans Hagen
-
Peter Rolf