Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Cedric Mauclair
On Wed, Oct 27, 2010 at 22:08, Michael Murphy michael.mur...@uni-ulm.de 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
 \pgfu...@definecolor{black}{gray}{0}
 \pgfu...@definecolor{gray}{gray}{0.5}
 \pgfu...@definecolor{lightgray}{gray}{0.9}
 \pgfu...@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.

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?

Regards.

-- Cédric


 into

 local cv = attributes.colors.values

 Just guess, untested.

 Nope, doesn't work. Using

 local colors = colors or { }

 gets me a little further, but then complains that 'value' is a nil value. I
 don't know enough Lua to fix this either. Strangely, it seems to work on
 some older MkIV versions of ConTeXt...

 Michael.
 ___
 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
 ___

___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Cedric Mauclair
Actually, the opacity works great!

-- Cédric



On Thu, Oct 28, 2010 at 09:54, Cedric Mauclair
cedric.maucl...@gmail.com wrote:
 On Wed, Oct 27, 2010 at 22:08, Michael Murphy michael.mur...@uni-ulm.de 
 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
 \pgfu...@definecolor{black}{gray}{0}
 \pgfu...@definecolor{gray}{gray}{0.5}
 \pgfu...@definecolor{lightgray}{gray}{0.9}
 \pgfu...@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.

 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?

 Regards.

 -- Cédric


 into

 local cv = attributes.colors.values

 Just guess, untested.

 Nope, doesn't work. Using

 local colors = colors or { }

 gets me a little further, but then complains that 'value' is a nil value. I
 don't know enough Lua to fix this either. Strangely, it seems to work on
 some older MkIV versions of ConTeXt...

 Michael.
 ___
 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
 ___


___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Marius
Here is the fixed script.

On 27 October 2010 23:08, Michael Murphy michael.mur...@uni-ulm.de 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
 \pgfu...@definecolor{black}{gray}{0}
 \pgfu...@definecolor{gray}{gray}{0.5}
 \pgfu...@definecolor{lightgray}{gray}{0.9}
 \pgfu...@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)

 into

 local cv = attributes.colors.values

 Just guess, untested.

 Nope, doesn't work. Using

 local colors = colors or { }

 gets me a little further, but then complains that 'value' is a nil value. I
 don't know enough Lua to fix this either. Strangely, it seems to work on
 some older MkIV versions of ConTeXt...

 Michael.
 ___
 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
 ___



colorfix.tex
Description: TeX document
___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Hans Hagen

On 28-10-2010 9:54, Cedric Mauclair wrote:

On Wed, Oct 27, 2010 at 22:08, Michael Murphymichael.mur...@uni-ulm.de  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
\pgfu...@definecolor{black}{gray}{0}
\pgfu...@definecolor{gray}{gray}{0.5}
\pgfu...@definecolor{lightgray}{gray}{0.9}
\pgfu...@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(\\pgfu...@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(\\pgfu...@definecolor{%s}{gray}{%1.3f}, 
name, cv[2]))

elseif model == 3 then

texsprint(prtcatcodes,format(\\pgfu...@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\pgfu...@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
-
% 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\pgfu...@aux@r...@hook{
  \pgfu...@iffileexists{\jobname.pgf}{\input \jobname.pgf\relax}{}
  \csname newwrite\endcsname\pgfu...@auxout
  \csname 

Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Hans Hagen

On 28-10-2010 10:24, Cedric Mauclair wrote:

Actually, the opacity works great!


Officially it could hook into the context transparency model but I guess 
that that is too much hassle.


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
-
___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-28 Thread Cedric Mauclair
Sadly no. I once tried to modify it to make it work and I ended up
with what I proposed. Not very nice, but worked for me.

Thanks for your solution.

-- Cédric



On Thu, Oct 28, 2010 at 13:46, Hans Hagen pra...@wxs.nl wrote:

 \ifdefined\PDFcolor \else

  \ctxlua{function lpdf.pdfcolor(attribute) context(lpdf.color(1,attribute))
 end}

  \def\PDFcolor#1{\ctxlua{lpdf.pdfcolor(\thecolorattribute{#1})}}

 \fi

___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-27 Thread Cedric Mauclair
Hi,

Same problem here with the latest TikZ 2.10.

Regards.

-- Cédric



On Tue, Oct 26, 2010 at 12:20, Michael Murphy michael.mur...@uni-ulm.de wrote:
 Hi,

 I've been trying to get colors to work in TikZ, and found a nice fix by
 Aditya here:

 http://archive.contextgarden.net/message/20100120.220124.f2d3f8bc.en.html

 The problem is that the lua script doesn't work: I get a problem with
 'colors'.

 LuaTeX error main ctx instance:13: attempt to index global 'colors' (a
 nil value)
 stack traceback:
        main ctx instance:13: in function 'registercolor'
        main ctx instance:1: in main chunk.

 The input file from Aditya (called colorfix.tex) is

 \startluacode
  pgfutil = pgfutil or { }
  local texsprint, format = tex.sprint, string.format
  local prtcatcodes = tex.prtcatcodes

  function pgfutil.unsupported_color(name)
    texsprint(prtcatcodes,format(\\PackageError{pgf}{color %s has
 unsupported model}{}, name))
    texsprint(prtcatcodes,format(\\pgfu...@definecolor{%s}{gray}{0},
 name))
  end

  function pgfutil.registercolor(name, attributes)
    print(name, attributes)
    local cv = colors.value(attributes)
    if cv then
      local model = cv[1]
      if model == 1 then
        print(model=1)
        texsprint(prtcatcodes,format(\\pgfu...@definecolor{%s}{gray}{%
 1.3f}, name, cv[2]))
      elseif model == 3 then
        print(model=2)
        texsprint(prtcatcodes,format(\\pgfu...@definecolor{%s}{rgb}{%
 1.3f,%1.3f,%1.3f}, name, cv[3], cv[4], cv[5]))
      else
        print(no model)
        pgfutil.unsupported_color(name)
      end
    else
        print(no color)
        pgfutil.unsupported_color(name)
    end
  end
 \stopluacode

 \unprotect
 \def\pgfu...@registercolor#1%
  {\ctxlua{pgfutil.registercolor(#1,\thecolorattribute       {#1})}}
 \protect

 and my test file is

 \usemodule[tikz]
 \input colorfix

 \definecolor[mycolor][r=1,g=0,b=1]

 \starttext
 \starttikzpicture
 \fill[mycolor] (0,0) circle (1);
 \stoptikzpicture
 \stoptext

 I'm running the latest beta.

 ___
 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
 ___

___
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
___


Re: [NTG-context] ConText, TikZ and definecolor: undefined control sequence

2010-10-27 Thread Michael Murphy

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
\pgfu...@definecolor{black}{gray}{0}
\pgfu...@definecolor{gray}{gray}{0.5}
\pgfu...@definecolor{lightgray}{gray}{0.9}
\pgfu...@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)

into

local cv = attributes.colors.values

Just guess, untested.


Nope, doesn't work. Using

local colors = colors or { }

gets me a little further, but then complains that 'value' is a nil 
value. I don't know enough Lua to fix this either. Strangely, it seems 
to work on some older MkIV versions of ConTeXt...


Michael.
___
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
___