[NTG-context] change numeral to string in Metafun
haksan at me.com
Wed Jul 14 02:19:54 CEST 2010
I'd like to draw boxes with a label in a certain rule.
I define drawbox macro for it.
It receives 3 numbers, (the height of box, x position, y position).
I'd like to label the height of the box in the middle of the box.
label( h ,(3s*u+u, t*u + h*u/2)); %h is a received numeral.
But it is not working. If I change h to "letter" in label command, it is working.
So, I'd like to know how to put received numeral(the height of the box) as a label.
Or, how to change the value of a variable to a string.
Here is a working sample code.
u := 0.5cm;
def drawbox (expr h, s, t) =
draw unitsquare xyscaled (1cm, h*u) shifted (3*s*u, t*u);
label("1",(3s*u+u, t*u + h*u/2));
drawbox (3, 0, 0);
drawbox (6, 0, 3);
drawbox (2, 1, 0);
drawbox (1, 1, 2);
drawbox (3, 2, 0)
drawbox (4, 2, 3)
More information about the ntg-context