On 28-10-2010 9:54, Cedric Mauclair wrote: > On Wed, Oct 27, 2010 at 22:08, Michael Murphy wrote: >> On 27/10/2010 19:18, Marius wrote: >>> >>> Hello, >>> I had the same problem, so I desided to define colors by hand. >>> >>> \definecolor [lightgray] [h=D3D3D3] >>> >>> \usemodule[tikz] >>> >>> \unprotect >>> \pgfutil@definecolor{black}{gray}{0} >>> \pgfutil@definecolor{gray}{gray}{0.5} >>> \pgfutil@definecolor{lightgray}{gray}{0.9} >>> \pgfutil@definecolor{white}{gray}{1} >>> \protect >> >> Yes, this is what I've resorted to. But it would be nice to define things >> properly. >> >>> If you want to fix script, you need to change line: >>> >>> local cv = colors.value(attributes) > The table "colors" is expected to have a function named "value" that > take the "attributes" parameter as its sole parameter itself. It then > assigns the result to the local variable cv. After some research, > adding "local colors = global.attributes.colors" below the line > "local prtcatcodes = tex.prtcatcodes" works. There is a catch however, > you can't use opacity on these colors. I suppose we have to generate > all the transparency level by using spot colors or something like > that. There are several solutions to the problem. \usemodule[tikz] \startmode[mkiv] \startluacode thirddata = thirddata or { } thirddata.pgf = thirddata.pgf or { } local texsprint, prtcatcodes, format = tex.sprint, tex.prtcatcodes, string.format local function unsupported_color(name) texsprint(prtcatcodes,format("\\PackageError{pgf}{color %s has unsupported model}{}", name)) texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{0}", name)) end local colors = attributes.colors function thirddata.pgf.registercolor(name,attribute) -- solution 1 local cv = colors.value(attribute) if cv then local model = colors.forcedmodel(cv[1]) if model > 3 then model = 3 -- no cmyk or spot or multitone end if model == 2 then texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{gray}{%1.3f}", name, cv[2])) elseif model == 3 then texsprint(prtcatcodes,format("\\pgfutil@definecolor{%s}{rgb}{%1.3f,%1.3f,%1.3f}", name, cv[3], cv[4], cv[5])) else unsupported_color(name) end else unsupported_color(name) end end function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute)) end \stopluacode \stopmode \unprotect % solution 1 (also fallback when cmyk is used): % \def\PDFcolor#1% % {\ctxlua{thirddata.pgf.pdfcolor(\thecolorattribute{#1})}} % solution 2 (faster as less parsing at the tex end): % \def\pgfutil@registercolor#1% % {\ctxlua{thirddata.pgf.registercolor("#1",\thecolorattribute{#1})}} % solution 3 (backward compatible): \def\PDFcolor#1% {\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \protect \definecolor[mycolora][r=1,g=0,b=1] \definecolor[mycolorb][m=1] \starttext \starttikzpicture \fill[mycolora] (0,0) circle (2); \fill[mycolorb] (0,0) circle (1); \stoptikzpicture \stoptext I'll define \pdfcolor for this purpose as that's what tikz expects. > However, I still need to > add"\let\appendtoPDFdocumentcolorspaces\gobbleoneargument" > "\let\appendtoPDFdocumentextgstates\gobbleoneargument" and > "\let\PDFcolor\gobbleoneargument" before loading the TikZ module in > order for my documents to build without errors. These macros used to > be defined in mkii (spec-fdf.mkii) and TikZ relies on them > (tex/generic/pgf/utilities/pgfutil-context.def) but not anymore in > mkiv since the color support has changed between mkii and mkiv. I > suppose they had to do with the color support for PDF files, but > letting them gobble their argument still seems to work. On what side > should this problem be looked into: ConTeXt or TikZ? In pgfutil-context.def there should be no such commands called when mkiv is used. Isn't there a \doifmodeelse {mkiv} { ... section? anyhow, in that section one can add \ifdefined\PDFcolor \else \ctxlua{function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute)) end} \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \fi (in the next beta this is not needed as \PDFcolor is defined then) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------