Taco Hoekwater wrote:
Hi Peter,
def draw_vline(expr h,a,b,c)= draw (.5u,.5u)--(.5u,h*u-.5u) withpen pensquare scaled u
That scales the whole draw statement, just like if you had said:
draw (.5u,.5u)--(.5u,h*u-.5u) scaled u withpen pensquare
So you need to do it like this:
draw (.5u,.5u)--(.5u,h*u-.5u) withpen (pensquare scaled u)
Hi Taco, thanks for the answer. Sadly I doesn't work here; all drawn lines are still fixed to 1pt. Even my own defined pen (upen) in draw_hline is completely ignored. Greetings, Peter
Cheers, Taco _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
\setupoutput[pdftex] \setupcolors[state=start] \starttext \startMPinclusions % default unit u:= 2 ; % u:=1 works, u:=2 doesn't pen upen ; upen = makepen(unitsquare scaled u shifted -(.5u,.5u)) ; % width, height, shift-x, shift-y, color def fill_square(expr w,h,a,b,c)= fill unitsquare xyscaled(w*u,h*u) shifted (a*u,b*u) withcolor c enddef ; def fill_hline(expr w,a,b,c)= fill_square(w,u,a,b,c) enddef ; def fill_vline(expr h,a,b,c)= fill_square(u,h,a,b,c) enddef ; % the drawing macros always use a pen of 1pt ; % even with an extra defined pen def draw_hline(expr w,a,b,c)= draw (.5u,.5u)--(w*u-.5u,.5u) withpen upen shifted (a*u,b*u) withcolor c enddef ; def draw_vline(expr h,a,b,c)= draw (.5u,.5u)--(.5u,h*u-.5u) withpen (pensquare scaled u) shifted (a*u,b*u) withcolor c enddef ; def draw_frame(expr w,h,a,b,c)= draw (.5u,.5u)--(w*u-.5u,.5u)--(w*u-.5u,h*u-.5u)--(.5u,h*u-.5u)--cycle withpen (pensquare scaled u) shifted (a*u,b*u) withcolor c enddef ; \stopMPinclusions \startMPpage fill_hline(20,5,5,red) ; fill_vline(20,5,5,red) ; draw_vline(20,5,25,blue) ; draw_hline(20,25,5,blue) ; draw_frame(50,50,0,0,black) ; \stopMPpage \stoptext