From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/63014 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: ConText, TikZ and definecolor: undefined control sequence Date: Thu, 28 Oct 2010 13:46:25 +0200 Message-ID: <4CC96291.9010508@wxs.nl> References: <1288088447.2222.4.camel@silver-fox> <4CC886AF.2010005@uni-ulm.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------060600090006060908070104" X-Trace: dough.gmane.org 1288266411 32759 80.91.229.12 (28 Oct 2010 11:46:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 28 Oct 2010 11:46:51 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Oct 28 13:46:44 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PBQwN-0003WQ-WD for gctc-ntg-context-518@m.gmane.org; Thu, 28 Oct 2010 13:46:44 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9797BCA7A1; Thu, 28 Oct 2010 13:46:42 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id RLwidVJ0-GWk; Thu, 28 Oct 2010 13:46:39 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id E4BE1CA796; Thu, 28 Oct 2010 13:46:38 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 752B8CA796 for ; Thu, 28 Oct 2010 13:46:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26OcPByxv+lO for ; Thu, 28 Oct 2010 13:46:34 +0200 (CEST) Original-Received: from filter3-nij.mf.surf.net (filter3-nij.mf.surf.net [195.169.124.154]) by balder.ntg.nl (Postfix) with ESMTP id 82FE0CA781 for ; Thu, 28 Oct 2010 13:46:34 +0200 (CEST) Original-Received: from smtp.ziggozakelijk.nl (D57D1DA2.static.ziggozakelijk.nl [213.125.29.162]) by filter3-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o9SBkVXI010247 for ; Thu, 28 Oct 2010 13:46:33 +0200 X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by pragma-net.nl (SurgeMail 4.3g4) with ESMTP id 11743-1713362 for multiple; Thu, 28 Oct 2010 13:43:36 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.11) Gecko/20101013 Lightning/1.0b2 Thunderbird/3.1.5 ThunderBrowse/3.3.2 In-Reply-To: X-Authenticated-User: hagen@controller-9 X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.125.29.162; country=NL; region=11; city=Den Haag; latitude=52.0833; longitude=4.3000; http://maps.google.com/maps?q=52.0833,4.3000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0dDobKvm6 - 5c12726ee649 - 20101028 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.154 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:63014 Archived-At: This is a multi-part message in MIME format. --------------060600090006060908070104 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 ----------------------------------------------------------------- --------------060600090006060908070104 Content-Type: text/x-tex; name="t-tikz-hans.tex" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="t-tikz-hans.tex" % Copyright 2006 by Till Tantau % % This file may be distributed and/or modified % % 1. under the LaTeX Project Public License and/or % 2. under the GNU Public License. % % See the file doc/generic/pgf/licenses/LICENSE for more details. % The aux files, needed for reading back coordinates \def\pgfutil@aux@read@hook{ \pgfutil@IfFileExists{\jobname.pgf}{\input \jobname.pgf\relax}{} \csname newwrite\endcsname\pgfutil@auxout \csname openout\endcsname\pgfutil@auxout\jobname.pgf } % XColor-like support for ConTeXt \def\pgfutil@definecolor#1#2#3{\csname pgfutil@emu@#2\endcsname{#1}#3\@nil} \def\pgfutil@emu@rgb#1#2,#3,#4\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#3,#4}}} \def\pgfutil@emu@gray#1#2\@nil{\expandafter\def\csname\string\color@#1\endcsname{\xcolor@{}{}{rgb}{#2,#2,#2}}} \pgfutil@definecolor{white}{gray}{1} \pgfutil@definecolor{black}{gray}{0} \pgfutil@definecolor{gray}{gray}{0.5} \pgfutil@definecolor{red}{rgb}{1,0,0} \pgfutil@definecolor{green}{rgb}{0,1,0} \pgfutil@definecolor{blue}{rgb}{0,0,1} \pgfutil@definecolor{cyan}{rgb}{0,1,1} \pgfutil@definecolor{magenta}{rgb}{1,0,1} \pgfutil@definecolor{yellow}{rgb}{1,1,0} \pgfutil@definecolor{orange}{rgb}{1,0.5,0} \pgfutil@definecolor{violet}{rgb}{0.5,0,0.5} \pgfutil@definecolor{purple}{rgb}{0.75,0,0.25} \pgfutil@definecolor{brown}{rgb}{0.75,0.5,0.25} \def\pgfutil@color#1{% \pgfutil@colorlet{.}{#1}% \pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp% {% \pgfsysprotocol@setcurrentprotocol\pgfutil@empty% \pgfsysprotocol@bufferedtrue% \pgfsetcolor{.}% \expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}% }% \pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp% \aftergroup\pgfutil@reset@color% } \def\pgfutil@extractcolorspec#1#2{% \def#2{{#1}}% } \def\pgfutil@convertcolorspec#1#2#3{% \edef#3{\expandafter\expandafter\expandafter\pgfutil@emu@select\csname\string\color@#1\endcsname}% } \def\pgfutil@doifcolorelse#1#2#3{% \expandafter\ifx\csname\string\color@#1\endcsname\relax% \doifcolorelse{#1}{\let\pgf@next=\pgfutil@firstoftwo}{\let\pgf@next=\pgfutil@secondoftwo}% \else \let\pgf@next=\pgfutil@firstoftwo% \fi% \pgf@next{#2}{#3}% } \def\pgfutil@reset@color{% \pgfsysprotocol@getcurrentprotocol\pgfutil@emu@temp% {% \pgfsysprotocol@setcurrentprotocol\pgfutil@empty% \pgfsysprotocol@bufferedtrue% \pgfsetcolor{.}% \expandafter\pgfsys@outerinvoke\expandafter{\pgfsysprotocol@currentprotocol}% }% \pgfsysprotocol@setcurrentprotocol\pgfutil@emu@temp% } \expandafter\def\csname\string\color@.\endcsname{\xcolor@{}{}{rgb}{0,0,0}} \def\pgfutil@colorlet#1#2{% \edef\pgf@marshal{#2}% \expandafter\pgfutil@in@\expandafter!\expandafter{\pgf@marshal}% \ifpgfutil@in@% % compute mixture {% \expandafter\pgfutil@emu@mix\pgf@marshal!white!\@nil% \xdef\pgf@marshal{\noexpand\def\expandafter\noexpand\csname\string\color@#1\endcsname{% \noexpand\xcolor@{}{}{rgb}{\pgf@sys@tonumber\pgf@xa,\pgf@sys@tonumber\pgf@xb,\pgf@sys@tonumber\pgf@xc}}}% }% \pgf@marshal% \else% \expandafter\ifx\csname\string\color@#2\endcsname\relax% \pgfutil@registercolor{#2}% \fi% \edef\pgf@marshal{\noexpand\let\expandafter\noexpand\csname\string\color@#1\endcsname=% \expandafter\noexpand\csname\string\color@#2\endcsname}% \pgf@marshal% \fi% } \def\pgfutil@emu@mix#1!#2!#3!#4\@nil{% \expandafter\ifx\csname\string\color@#1\endcsname\relax% \pgfutil@registercolor{#1}% \fi% \expandafter\ifx\csname\string\color@#3\endcsname\relax% \pgfutil@registercolor{#3}% \fi% \expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#1\endcsname% \pgf@ya=\pgf@xa% \pgf@yb=\pgf@xb% \pgf@yc=\pgf@xc% \expandafter\expandafter\expandafter\pgfutil@emu@unpack\csname\string\color@#3\endcsname% \c@pgf@counta=#2\relax% \c@pgf@countb=100\relax% \advance\c@pgf@countb by-\c@pgf@counta\relax% \pgf@xa=\c@pgf@countb\pgf@xa% \advance\pgf@xa by\c@pgf@counta\pgf@ya% \divide\pgf@xa by 100\relax% \pgf@xb=\c@pgf@countb\pgf@xb% \advance\pgf@xb by\c@pgf@counta\pgf@yb% \divide\pgf@xb by 100\relax% \pgf@xc=\c@pgf@countb\pgf@xc% \advance\pgf@xc by\c@pgf@counta\pgf@yc% \divide\pgf@xc by 100\relax% } \def\pgfutil@emu@unpack#1#2#3#4#5{% \pgfutil@emu@@unpack#5\@nil% } \def\pgfutil@emu@@unpack#1,#2,#3\@nil{% \pgf@xa=#1pt% \pgf@xb=#2pt% \pgf@xc=#3pt% } \def\pgfutil@emu@select#1#2#3#4#5{#5} \def\pgfutil@registercolor#1{% \edef\pgf@temp{\PDFcolor{#1}}% \edef\pgf@marshal{\noexpand\pgfutil@in@{ g}{\pgf@temp}}% \pgf@marshal% \ifpgfutil@in@% \expandafter\pgfutil@context@parse@gray\pgf@temp\pgf@stop{#1}% \else% \edef\pgf@marshal{\noexpand\pgfutil@in@{ rg}{\pgf@temp}}% \pgf@marshal% \ifpgfutil@in@% \expandafter\pgfutil@context@parse@rgb\pgf@temp\pgf@stop{#1}% \else% \PackageError{pgf}{Color #1 has an unsupported color model.}{}% \pgfutil@definecolor{#1}{gray}{0} \fi% \fi% } \def\pgfutil@context@parse@gray#1 g#2\pgf@stop#3{% \pgfutil@definecolor{#3}{gray}{#1} } \def\pgfutil@context@parse@rgb#1 #2 #3 rg#4\pgf@stop#5{% \pgfutil@definecolor{#5}{rgb}{#1,#2,#3} } % Make this command available in general: \let\colorlet=\pgfutil@colorlet % pgfutil@minipage \def\pgfutil@minipage[#1]#2{% \hbox to#2\bgroup% \hsize=#2\relax% \vbox\bgroup\leavevmode% } \def\pgfutil@endminipage{\egroup\egroup} % Driver detector (how should we do this in ConTeXt?) : \ifx\pdfoutput\@undefined\newcount\pdfoutput\fi \ifx\pdfoutput\relax\newcount\pdfoutput\fi \def\pgfutil@guessdriver{ \ifx\XeTeXversion\@undefined \ifx\preloadedspecials\@undefined% \ifcase\pdfoutput% \def\pgfsysdriver{pgfsys-dvips.def}% \else% \def\pgfsysdriver{pgfsys-pdftex.def}% pdfTeX & LuaTeX \fi% \else% \pgfutil@driver@if@in{postscript}{pgfsys-dvips.def} \pgfutil@driver@if@in{tpd}{pgfsys-pdftex.def} \pgfutil@driver@if@in{dpm}{pgfsys-dvipdfm.def} \pgfutil@driver@if@in{dpx}{pgfsys-dvipdfmx.def} \pgfutil@driver@if@in{xetex}{pgfsys-xetex.def} \ifx\pgfsysdriver\relax% \PackageWarning{pgf}{I was not able to discern the driver, the preloaded specials were \preloadedspecials. I am going to use pgfsys-dvips.def}% \def\pgfsysdriver{pgfsys-dvips.def} \fi% \fi \else \def\pgfsysdriver{pgfsys-xetex.def}% should be right \fi } \def\pgfutil@driver@if@in#1#2{% \edef\pgf@marshal{\noexpand\pgfutil@in@{#1}{\preloadedspecials}} \pgf@marshal \ifpgfutil@in@% \def\pgfsysdriver{#2}% \fi% } % Global colors \let\pgfutil@globalcolorsfalse=\relax \let\pgfutil@globalcolorstrue=\relax % Font stuff \def\pgfutil@font@tiny{\tfxx} \def\pgfutil@font@scriptsize{\tfxx} \def\pgfutil@font@footnotesize{\tfx} \def\pgfutil@font@small{\tfx} \def\pgfutil@font@normalsize{\tf} \def\pgfutil@font@large{\tfa} \def\pgfutil@font@Large{\tfb} \def\pgfutil@font@huge{\tfc} \def\pgfutil@font@Huge{\tfc} \def\pgfutil@font@itshape{\it} \def\pgfutil@font@bfseries{\bf} \let\pgfutil@font@normalfont=\tf \let\pgfutil@selectfont=\tf % Extra counters, registers, boxes \newcount\pgfutil@tempcnta \newcount\pgfutil@tempcntb \newbox\pgfutil@tempboxa \newdimen\pgfutil@tempdima \newdimen\pgfutil@tempdimb \newbox \pgfutil@voidb@x \newtoks \pgfutil@toks@ % Module stuff \def\pgfutil@usemodule#1{\usemodule[#1]} % % % % begin patches by HH % % % % \let\pgfutil@insertatbegincurrentpagefrombox\flushatshipout \let\pgfutil@insertatbegincurrentpage \flushatshipout \def\pgfutil@insertatbegineverypage #1{\appendtoks#1\to\everyshipout} % space removed after #1 \let\pgfutil@setuppdfresources \relax \doifmodeelse {mkiv} { \def\pgf@sys@pdf@pdfbackendset@one#1#2% {\normalexpanded{\noexpand\pgf@sys@pdf@pdfbackendset@two\noexpand#1#2\relax}} \def\pgf@sys@pdf@pdfbackendset@two#1/#2 #3\relax {#1{#2}{#3}} \def\pgf@sys@pdf@addtopageresource@pattern {\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetpattern} \def\pgf@sys@pdf@addtopageresource@colorspace{\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetcolorspace} \def\pgf@sys@pdf@addtopageresource@extgstate {\pgf@sys@pdf@pdfbackendset@one\pdfbackendsetextgstate} \def\pgf@sys@pdf@possible@resources {\pdfbackendcurrentresources} \def\pgf@sys@pdf@check@resources {} \ifdefined\PDFcolor \else \ctxlua{function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute)) end} \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}} \fi } { \def\pgf@sys@pdf@addtopageresource@extgstate {\appendtoPDFdocumentextgstates } \def\pgf@sys@pdf@addtopageresource@colorspace {\appendtoPDFdocumentcolorspaces} \def\pgf@sys@pdf@addtopageresource@pattern {\appendtoPDFdocumentpatterns } \def\pgf@sys@pdf@possible@resources {\currentPDFresources} \def\pgf@sys@pdf@check@resources {} } \let\pgf@sys@addpdfresource@extgs@plain \pgf@sys@pdf@addtopageresource@extgstate \let\pgf@sys@addpdfresource@patterns@plain \pgf@sys@pdf@addtopageresource@pattern \let\pgf@sys@addpdfresource@colorspaces@plain\pgf@sys@pdf@addtopageresource@colorspace \let\pgf@sys@pdf@check@resources@plain \pgf@sys@pdf@check@resources \pgf@sys@addpdfresource@colorspaces@plain{/pgfprgb [/Pattern /DeviceRGB]} % % % % end patches by HH % % % % % Do something at the end of a job \appendtoks \the\pgfutil@everybye \to \everybye % The following is still messy and needs to be cleanup up (everything % prefixed by pgfutil@): \def\PackageInfo#1#2{} \def\PackageWarning#1#2{\immediate\write17{Package #1: Warning! #2.}}% \def\PackageError#1#2#3{\immediate\write17{Package #1: Error! #2.}}% \long\def\AtBeginDocument#1{#1}% \endinput --------------060600090006060908070104 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --------------060600090006060908070104--