[metapost] Redefine ..
Hans Hagen
pragma at wxs.nl
Mon Jun 4 19:08:18 CEST 2012
On 4-6-2012 18:00, Troy Henderson wrote:
> I am drawing 3D graphics, and many of my "points" are colors instead of
> pairs. Of course, the colors are projected to pairs eventually, but I
> would like to define paths of colors directly with .. by doing something
> like
>
> path p;
> p:=(1,2,3)..(4,5,6)..(7,8,9);
>
> I have a vardef P that transforms colors into pairs, and thus I can always
> just do
>
> p:=P(1,2,3)..P(4,5,6)..P(7,8,9);
>
> but I would like to be able to omit this P usage. My attempt thusfar is
>
> ---
> def pathnode primary a =
> if color a:
> P(a)
> else:
> a
> fi;
> enddef;
>
> primarydef a .. b =
> pathnode(a) .. pathnode(b)
> enddef;
> ---
>
> but this is not working. I would appreciate any insight into how I might
> fix this so that I can use .. between pairs.
def P (expr a) = (redpart a, greenpart a) enddef ;
def pathnode (expr a) =
if rgbcolor a :
P(a)
else :
a
fi
enddef ;
let normaldots = .. ;
primarydef a .. b =
pathnode(a) normaldots pathnode(b)
enddef;
draw (1,1,9) .. (2,1,6) .. (3,2,5) .. (4,1,5) ;
however, the next challenge is to catch a 'cycle'.
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
-----------------------------------------------------------------
More information about the metapost
mailing list