Hello, I tried to custumise the line drawing for Wall subtype blocks but I did not succeed. I try to use the same technique (and syntaxe) used for others kinds of lines but here, it's not a line but a SUBTYPE of line Is it possible ? and what is the syntaxe ? Thanks, Here my code, written in the layout bloc code metapost def l_wall_blocks_PINEE (expr P) = % pickup PenD; % draw P withcolor red; T:=identity; cas := 0; dlzka := arclength P; if dlzka > 0: mojkrok:=adjust_step(dlzka, 1.5u); pickup PenA; forever: t1 := arctime (cas + mojkrok*1/10) of P; t2 := arctime (cas + mojkrok*9/10) of P; q := ((point t1 of P) + .4u * unitvector(thdir(P,t1) rotated -90)) -- (subpath (t1,t2) of P) -- ((point t2 of P) + .4u * unitvector(thdir(P,t2) rotated -90)); thdraw q randomized (u/6); cas := cas + mojkrok; exitif cas > dlzka - (2*mojkrok/3); % for rounding errors endfor; fi; enddef; initsymbol("l_wall_blocks_PINEE"); #symbol-assign line wall_blocks PINEE # let l_wall_blocks = l_wall_blocks_PINEE endcode The symbol-assign command did not work, and the "let l_wall_blocks = l_wall_blocks_PINEE" generate an error on compiling An extract of the logs ####################### metapost log file ######################## This is MetaPost, Version 0.641 (Web2c 7.5.2) (mem=mpost 2004.3.2) 9 APR 2009 10:25 **data.mp (data.mp [4001] [4002] [4003] [4004] [4005] [4006] [4007] ! Extra tokens will be flushed. <to be read again> string mapsymbol->string .s,stype,lname,ID;stype=substring(0,1)of(EXPR0);lname=(EXPR... l.3748 mapsymbol("a_bedrock","UIS",false) ; I've just read as much of that statement as I could fathom, so a semicolon should have been next. It's very puzzling... but I'll try to get myself back together, by ignoring everything up to the next `;'. Please insert a semicolon now in front of anything that you don't want me to delete. (See Chapter 27 of The METAFONTbook for an example.)
stype "a" ! Equation cannot be performed (numeric=string). <to be read again> ; mapsymbol->...me,ID;stype=substring(0,1)of(EXPR0);
lname=(EXPR0)&"_"&(EXPR1);... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm sorry, but I don't know how to make such things equal. (See the two expressions just above the error message.)
lname "a_bedrock_UIS" ! Equation cannot be performed (numeric=string). <to be read again> ; mapsymbol->...of(EXPR0);lname=(EXPR0)&"_"&(EXPR1);
ID:="ID_"&lname;if(known.s... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm sorry, but I don't know how to make such things equal. (See the two expressions just above the error message.)
"ID_" lname ! Not implemented: (string)&(unknown numeric). <to be read again> ; mapsymbol->...(EXPR0)&"_"&(EXPR1);ID:="ID_"&lname;
if(known.scantokens.ID):if... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm afraid I don't know how to apply that operation to that combination of types. Continue, and I'll return the second argument (see above) as the result of the operation.
lname ! Not a string. <to be read again> ) mapsymbol->...="ID_"&lname;if(known.scantokens.ID) :if.stype="a":s="def "&(EX... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm going to flush this expression, since scantokens should be followed by a known string.
! A primary expression can't begin with `:'. <inserted text> 0 <to be read again> : mapsymbol->..."ID_"&lname;if(known.scantokens.ID): if.stype="a":s="def "&(EXP... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm afraid I need some sort of value in order to continue, so I've tentatively inserted `0'. You may want to delete this zero and insert something else; see Chapter 27 of The METAFONTbook for an example. ! Missing `)' has been inserted. <to be read again> : mapsymbol->..."ID_"&lname;if(known.scantokens.ID): if.stype="a":s="def "&(EXP... l.3748 mapsymbol("a_bedrock","UIS",false) ; I found no right delimiter to match a left one. So I've put one in, behind the scenes; this may fix the problem.
stype "a" ! Not implemented: (unknown numeric)=(string). <to be read again> : mapsymbol->...f(known.scantokens.ID):if.stype="a": s="def "&(EXPR0)&" = scant... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm afraid I don't know how to apply that operation to that combination of types. Continue, and I'll return the second argument (see above) as the result of the operation.
"a" ! Undefined condition will be treated as `false'. <to be read again> : mapsymbol->...f(known.scantokens.ID):if.stype="a": s="def "&(EXPR0)&" = scant... l.3748 mapsymbol("a_bedrock","UIS",false) ; The expression shown above should have had a definite true-or-false value. I'm changing it to `false'.
"let a_bedrock = " lname ! Not implemented: (string)&(unknown numeric). <to be read again> & mapsymbol->...";else:s="let "&(EXPR0)&" = "&lname&
";";fi;scantokens.s;elseif... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm afraid I don't know how to apply that operation to that combination of types. Continue, and I'll return the second argument (see above) as the result of the operation.
lname ";" ! Not implemented: (unknown numeric)&(string). <to be read again> ; mapsymbol->...se:s="let "&(EXPR0)&" = "&lname&";";
fi;scantokens.s;elseif(EXP... l.3748 mapsymbol("a_bedrock","UIS",false) ; I'm afraid I don't know how to apply that operation to that combination of types. Continue, and I'll return the second argument (see above) as the result of the operation. ! Inconsistent equation. <to be read again> ; mapsymbol->...se:s="let "&(EXPR0)&" = "&lname&";"; fi;scantokens.s;elseif(EXP... l.3748 mapsymbol("a_bedrock","UIS",false) ; The equation I just read contradicts what was said before. But don't worry; continue and I'll just ignore it. ! Redundant equation. <to be read again> ; mapsymbol->...R0)&" = "&lname&";";fi;scantokens.s; elseif(EXPR2):message("[Wa... l.3748 mapsymbol("a_bedrock","UIS",false) ; I already knew that this equation was true. But perhaps no harm has been done; let's continue.
Hi! The syntax for the symbol-assign with subtypes is using a colon: symbol-assign line wall:blocks PINEE yet, note that this is a therion command and not a metapost command. Therefore it should not be inside the code metapost section (though it works!?). On the other hand the "let" is a metapost command, and the line has to be terminated by a semicolon, or you get metapost errors. regards, Georg. Ps.: This is the redefinition of line wall:blocks, I did: def l_wall_blocks_AUT (expr P) = T:=identity; pickup PenC; laenge := arclength P; path block; path old_block; cur := 0; t:= arctime cur of P; % draw first block old_block := ( (.7u,-.35u)--(.85u,0.01u)--(.4u,.5u)--(.1u,.3u)--(-.0u,-.0u) ); block_width := (xpart urcorner old_block - xpart ulcorner old_block); old_block:=old_block rotated angle( thdir(P,0) ) shifted point t of P; thclean (old_block--cycle); thdraw old_block; cur := cur + block_width/2; t:= arctime cur of P; forever: % generate random block block := punked ( ( (.8u,-.35u)--(.85u,0.01u)--(.6u,.4u)--(.1u,.1u)--(-.0u,-.3u) ) randomized (0.3u) ) scaled (uniformdeviate(0.3)+.65) rotated (uniformdeviate(45)-15); % check width of block block_width := (xpart urcorner block - xpart ulcorner block); exitif cur > (laenge- 3.5*block_width/2); % find next position where the block fits in without intersecting the previous one forever: exitif xpart ( ((block--cycle) rotated angle(direction t of P) shifted point t of P) intersectiontimes old_block) < 0; cur:=cur+0.01u; t:= arctime cur of P; exitif cur > (laenge- 3.5*block_width/2); endfor; exitif cur > (laenge- 3.5*block_width/2); old_block:= block rotated angle(direction t of P) shifted point t of P; thclean (old_block--cycle); thdraw old_block; cur := cur + block_width/2; t:= arctime cur of P; endfor; % generate last block t:= arctime laenge-eps of P; block := (( (-.15u,-.35u)--(.0u,.0u)--(-.45u,.5u)--(-.75u,.3u)--(-.85u,-.0u)) ); block_width := (xpart urcorner block - xpart ulcorner block); % scale last block to fit in the remaining gap scale_factor:=(laenge-cur)/block_width; forever: exitif xpart ( ( (block) rotated angle (direction t of P) scaled scale_factor shifted (point t of P) ) intersectiontimes old_block) < 0; scale_factor:=scale_factor-0.001; endfor; thclean (block--cycle) rotated angle (direction t of P) scaled scale_factor shifted (point t of P); thdraw (block) rotated angle (direction t of P) scaled scale_factor shifted (point t of P); enddef; Gilbert Fernandes (mailinglist) schrieb:
Hello, I tried to custumise the line drawing for Wall subtype blocks but I did not succeed. I try to use the same technique (and syntaxe) used for others kinds of lines but here, it's not a line but a SUBTYPE of line Is it possible ? and what is the syntaxe ?
[...]
initsymbol("l_wall_blocks_PINEE"); #symbol-assign line wall_blocks PINEE # let l_wall_blocks = l_wall_blocks_PINEE endcode
The symbol-assign command did not work, and the "let l_wall_blocks = l_wall_blocks_PINEE" generate an error on compiling An extract of the logs [...]
participants (2)
-
Georg Pacher -
Gilbert Fernandes (mailinglist)