encoding utf-8 layout symbols #Put symbol assign after code to avoid confusion/overwrites code metapost def s_northarrow_CHED (expr rot) = T:=identity scaled 0.7 rotated -rot; thdraw (-1cm,-2cm)--(0,3cm)--(1cm,-2cm)--(0,0cm)--cycle; thfill (-1cm,-2cm)--(0,3cm)--(0,0cm)--cycle; enddef; initsymbol("s_northarrow_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 := punked (( (.65u,-.15u)--(.72u,0.05u)--(.55u,.15u)--(.23u,.17u)--(.0u,.03u)--(.05u,-.1u))randomized (0.1u)) scaled (uniformdeviate(0.3)+.65); 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 0 of P; thclean (old_block--cycle); thdraw old_block; cur := cur + block_width + 0.04u; forever: # generate random block block := punked( ((.65u,-.15u)--(.72u,0.05u)--(.55u,.15u)--(.2u,.17u)--(.0u,.03u)--(.05u,-.1u)randomized (0.1u) )) scaled (uniformdeviate(0.3)+.65) rotated (uniformdeviate(20)-10); # 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: cur:=cur+0.01u; t:= arctime cur of P; st:= arctime (cur+block_width/2) of P; exitif cur > (laenge- 3*block_width/2); exitif xpart ( ((block--cycle) rotated angle(direction st of P) shifted point t of P) intersectiontimes old_block) < 0; endfor; exitif cur > (laenge- 3*block_width/2); old_block:= block rotated angle(direction st of P) shifted point t of P; thclean (old_block--cycle); thdraw old_block; cur := cur + block_width + 0.04u; endfor; # generate last block block := (((.65u,-.15u)--(.72u,0.05u)--(.55u,.15u)--(.2u,.17u)--(.0u,.03u)--(.05u,-.1u)) ); block_width := (xpart urcorner block - xpart ulcorner block); # scale last block to fit in the remaining gap scale_factor:=(laenge-cur)/block_width; t:= arctime cur of P; st:= arctime (laenge+cur)/2 of P; forever: exitif scale_factor < 0; exitif xpart ( ( (block) rotated angle (direction st 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 st of P) scaled scale_factor shifted (point t of P); thdraw (block) rotated angle (direction st of P) scaled scale_factor shifted (point t of P); fi; enddef; initsymbol ("l_wall_blocks_CHED"); 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"); 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 symbol-assign special north-arrow CHED endlayout