Colored Lines Based On Attributes

View: New views
2 Messages — Rating Filter:   Alert me  

Colored Lines Based On Attributes

by Carl Magnuson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am attempting to color the walls of different systems with different colors using the -attr flag and a user defined wall:

portion of code in scrap:
line u:wall -attr color "(0.1, 0.2, 0.8);"
1392.9359853260457 -71.62435442682576
1395.5759853260456 125.20564557317425
endline

portion of code in layout:
def l_u_wall (expr P)= 
T:=identity;
if known(ATTR__color):
pickup PenA; 
draw P withpen PenA withcolor ATTR__color\n
fi;
enddef;

initsymbol(\"l_u_wall\");

I am not having any success however.  Is it possible to set and read attributes from lines as I am trying to do? Is somebody aware of an alternate way to pass in a color argument to the metapost definition (instead of defining separate walls for each different colored system)?

Thanks,

Carl

_______________________________________________
Therion mailing list
Therion@...
http://mailman.speleo.sk/mailman/listinfo/therion

Re: Colored Lines Based On Attributes

by Carl Magnuson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I figured it out with the following command:

"scantokens ATTR_color;\n" +

Scantokens evaluates the string it is applied to, so I just had to change ATTR_color to "color col; col:=red" for example.

Carl


On Sep 11, 2009, at 3:35 PM, Carl Magnuson wrote:

I am attempting to color the walls of different systems with different colors using the -attr flag and a user defined wall:

portion of code in scrap:
line u:wall -attr color "(0.1, 0.2, 0.8);"
1392.9359853260457 -71.62435442682576
1395.5759853260456 125.20564557317425
endline

portion of code in layout:
def l_u_wall (expr P)= 
T:=identity;
if known(ATTR__color):
pickup PenA; 
draw P withpen PenA withcolor ATTR__color\n
fi;
enddef;

initsymbol(\"l_u_wall\");

I am not having any success however.  Is it possible to set and read attributes from lines as I am trying to do? Is somebody aware of an alternate way to pass in a color argument to the metapost definition (instead of defining separate walls for each different colored system)?

Thanks,

Carl


_______________________________________________
Therion mailing list
Therion@...
http://mailman.speleo.sk/mailman/listinfo/therion