ConTeXt graphics example compilation

by Georges   Last Updated December 06, 2018 15:23 PM

Scratching my head to compile this example in the mkiv manual (p57).

Example run: $ context file.tex.

Am I missing something??

%engine=luatex    
\setuphead[section][style=\bfa]
\setupbodyfontenvironment[default][em=italic]

\startluacode
local template = [[
path p, q ; color c[] ;
c1 := \MPcolor{darkblue} ;
c2 := \MPcolor{darkred} ;
p := fullcircle scaled 50 ;
l := length p ;
n := %s ;
q := subpath (0,%s/n*l) of p ;
draw q withcolor c2 withpen pencircle scaled 1 ;
fill fullcircle scaled 5 shifted point length q of q withcolor c1 ;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 60 ;
draw boundingbox currentpicture withcolor c1 ;
currentpicture := currentpicture xsized(1cm) ;
]]
local function steps(n)
for i=0,n do
context.metafun.start()
context.metafun(template,n,i)
context.metafun.stop()
if i < n then
context.quad()
end
end
end
context.hbox(function() steps(10) end)
\stopluacode

Output:

tex error       > tex error on line 2 in file /Users/user/Desktop/coo/Untitled.tex: ! Argument of \meta_start_code_standard has an extra }

<inserted text> 
\par 
<to be read again> 
}
l.2 ...th p, q ; color c[] ;
    c1 := (0,0,0)white}
                                                   ;
    c2 := (0,0,0)black}...
<to be read again> 
}
l.4 }

}ontext.hbox(function() steps(10) end)

...
l.32 \stopluacode


 1     \setuphead[section][style=\bfa]
 2 >>  \setupbodyfontenvironment[default][em=italic]
 3     
 4     \startluacode
 5     local template = [[
 6         path p, q ; color c[] ;
 7         c1 := \MPcolor{white} ;
 8         c2 := \MPcolor{black} ;
 9         p := fullcircle scaled 50 ;
10         l := length p ;
11         n := %s ;
12         q := subpath (0,%s/n*l) of p ;

? 
Tags : luatex context


Related Questions


Getting started with LuaTeX and ConTeXt

Updated June 05, 2015 02:10 AM

How to make a font book in context/texlua?

Updated April 03, 2017 19:23 PM