Troy Henderson | 4 Jun 2012 18:00
Picon

Redefine ..

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.

Thanks in advance,

Troy Henderson

--
http://tug.org/metapost/

Gmane