encoding utf-8 layout symbols #Put symbol assign after code to avoid confusion/overwrites code metapost def l_u_rail (expr P) = T:=identity; cas := 0; dlzka := arclength P; mojkrok:=adjust_step(dlzka, 0.8u); pickup PenC; forever: t0 := arctime (cas) of P; t1 := arctime (cas + mojkrok*2/5) of P; t := arctime (cas + mojkrok/2) of P; t4 := arctime (cas + mojkrok*3/5) of P; t5 := arctime (cas + mojkrok) of P; thdraw (subpath (t0,t1) of P); thdraw (subpath (t4,t5) of P); drawdot (point t of P); #mark_ (P,t,0.02u); #mark_ (P,t,-0.02u); #f := (P,t,0.2u); #draw f; cas := cas + mojkrok; exitif cas > dlzka - (2*mojkrok/3); % for rounding errors endfor; enddef; initsymbol("l_u_rail") #text en line u:rail "Railing" def a_debris_CHED (expr p) = T:=identity; pickup PenC; path q, qq; q = bbox p; picture tmp_pic; tmp_pic := image( for i = xpart llcorner q step u until xpart urcorner q: for j = ypart llcorner q step u until ypart urcorner q: qq := punked (((-.2u,-.2u)--(.2u,-.2u)--(.2u,.2u)--(-.2u,.2u)--cycle) randomized (u/2)) rotated uniformdeviate(360) shifted ((i,j) randomized u); if xpart (p intersectiontimes qq) < 0: thclean qq; thdraw qq; fi; endfor; endfor; ); clip tmp_pic to p; draw tmp_pic; enddef; def a_sand_CHED(expr p) = T:=identity; % thclean p; pickup PenC; path q; q = bbox p; picture tmp_pic; tmp_pic := image( for i = xpart llcorner q step .3u until xpart urcorner q: for j = ypart llcorner q step .3u until ypart urcorner q: draw origin shifted ((i,j) randomized 0.2u) withpen PenC; endfor; endfor; ); clip tmp_pic to p; draw tmp_pic; enddef; def l_flowstone_CHED (expr P) = T:=identity; cas := 0; dlzka := arclength P; mojkrok:=adjust_step(dlzka, .25u); pickup PenC; t1:=0; forever: t2 := arctime (cas + mojkrok) of P; thdraw (point t1 of P){dir (angle(thdir(P,t1)) + 60)} .. {dir (angle(thdir(P,t2)) - 60)}(point t2 of P); cas := cas + mojkrok; exitif cas > dlzka + (mojkrok / 3); % for rounding errors t1:=t2; endfor; enddef; def l_overhang_CHED (expr P) = # taken from: def l_ceilingstep_SKBB (expr P) = T:=identity; cas := 0; dlzka := arclength P; #controls the length mojkrok:=adjust_step(dlzka, 0.3u); pickup PenC; forever: t1 := arctime (cas + mojkrok*1/5) of P; t := arctime (cas + mojkrok/2) of P; t2 := arctime (cas + mojkrok*4/5) of P; thdraw (subpath (t1,t2) of P); #controls the lengthof the tick mark_ (P,t,0.15u); cas := cas + mojkrok; exitif cas > dlzka - (2*mojkrok/3); % for rounding errors endfor; enddef; def l_pit_CHED (expr P) = T:=identity; cas := 0; dlzka := arclength P; mojkrok:=adjust_step(dlzka, 0.1u); pickup PenD; forever: t := arctime cas of P; mark_ (P,t,0.1u); cas := cas + mojkrok; exitif cas > dlzka + (mojkrok / 3); % for rounding errors endfor; pickup PenC; thdraw P; enddef; initsymbol ("l_flowstone_CHED"); initsymbol ("l_pit_CHED"); initsymbol ("l_overhang_CHED"); initsymbol ("a_sand_CHED"); initsymbol ("a_debris_CHED"); #derived from def l_pit_UIS (expr P) = def l_floorstep_CHED (expr P) = T:=identity; cas := 0; dlzka := arclength P; # Step leangth changed from 0.25 mojkrok:=adjust_step(dlzka, 0.12u); pickup PenD; forever: t := arctime cas of P; #length of tck shorted pit was 0.2 mark_ (P,t,0.1u); cas := cas + mojkrok; exitif cas > dlzka + (mojkrok / 3); % for rounding errors endfor; pickup PenC; thdraw P; enddef; initsymbol ("l_floorstep_CHED"); def l_wall_blocks_CHED (expr P) = T:=identity; pickup PenC; laenge := arclength P; path block; path old_block; cur := 0; #draw first block old_block := ( (.35u,-.15u)--(.42u,0.01u)--(.2u,.15u)--(.05u,.13u)--(-.0u,-.0u) ); block_width := (xpart urcorner old_block - xpart ulcorner old_block); t:= arctime (cur+block_width/2) of P; old_block:=old_block rotated angle( direction t of P) shifted point t of P; thclean (old_block--cycle); thdraw old_block; cur := cur + block_width; t:= arctime cur of P; forever: # generate random block block := punked ( ( (.4u,-.15u)--(.43u,0.01u)--(.3u,.14u)--(.05u,.11u)--(-.0u,-.13u) ) randomized (0.1u) ) scaled (uniformdeviate(0.3)+.65) rotated (uniformdeviate(30)-15); # check width of block block_width := (xpart urcorner block - xpart ulcorner block); exitif cur > (laenge- 3*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*block_width/2); endfor; exitif cur > (laenge- 3*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; t:= arctime cur of P; endfor; # generate last block block := (( (-.07u,-.15u)--(.0u,.0u)--(-.22u,.15u)--(-.37u,.13u)--(-.42u,-.0u)) ); block_width := (xpart urcorner block - xpart ulcorner block); t:= arctime (laenge+cur)/2 of P; # scale last block to fit in the remaining gap scale_factor:=(laenge-cur)/block_width; forever: exitif scale_factor < 0; 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; if scale_factor > 0: 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); fi; enddef; initsymbol ("l_wall_blocks_CHED"); endcode symbol-assign area blocks AUT symbol-assign area debris CHED symbol-assign area sand CHED symbol-assign line flowstone CHED symbol-assign line overhang CHED symbol-assign line pit CHED symbol-assign line wall:blocks CHED symbol-assign line floor-step CHED symbol-assign line wall:debris AUT #symbol-assign line wall:blocks AUT endlayout