;) it is in normal distribution code metapost def l_u_steps (expr P) = if known ATTR_c: c := scantokens ATTR_c; else: c := 2; fi; if ATTR__elevation: if (c < 2): thwarning("Invalid stairs definition (c<2)"); pickup PenA; draw P withcolor red; else: path PP; if (ypart point 0 of P) < (ypart point length P of P): PP := P; else: PP := reverse P; fi; path p; for j:=0 upto ((length PP) - 1): p := (point j of PP) -- (point (j + 1) of PP); c := ceiling(abs((ypart point 0 of p) - (ypart point length p of p)) / (0.2 / Scale * 72 / 2.54)); % 20 cm height if (c < 2): c:=2 fi; pair cp; cp = point length p of p - point 0 of p; dx := (xpart cp) / c; dy := (ypart cp) / c; cp := point 0 of p; for i:= 0 upto c - 1: l_border_visible(cp -- cp + (0,dy) -- cp + (dx,dy)); cp := cp + (dx, dy); endfor; %draw P; endfor; fi; else: if known ATTR_l: l := scantokens ATTR_l; else: l := (length(P)-2)/2; fi; if ((length(P) < 4) or (c < 2)) or ((odd length P) and (not known ATTR_l)): thwarning("Invalid stairs definition (l) " if c<2: &" (c<2)" fi); pickup PenA; draw P withcolor red; else: thclean P -- cycle; path p, q; p = subpath (1, 1+l) of P; q = reverse subpath (l+2, length(P)) of P; lp := arclength(p); lq := arclength(q); for i=1 upto c: l_border_visible(point(arctime ((i-1)/(c-1)*lp) of p) of p -- point(arctime ((i-1)/(c-1)*lq) of q) of q); endfor; l_border_visible(p); l_border_visible(q); drawoptions(withcolor 0.3*white); %p_label(decimal c, point 0.5 of P, 0, 6); drawoptions(); fi; fi; enddef; endcode m.
24. 1. 2017 v 23:51, Benedikt Hallinger via Therion <therion@speleo.sk>:
Hello, i get gray hair with metapost while i want to make a line symbol for ladders, so i can nicely draw them in my maps as the cave have alot of them.
The basic idea i had was, t define a symbol of one "rung" segment (rung and a little of either sides, like the letter "H") as a symbol picture. Then i wanted to apply this image seamlessly over the length of the given path (straight lines) What i have for now is the following, however it does not show at all (still shows a red line with symbol set AUT in effect), so i have no clue how to even debug this.
I tried to start with the example from thbook salted a little with peeks to the internal metapost codes.
Can someone assist please?
Thank you very much!
# Symbol for fixed ladder def l_fixedladder_SKBB (expr P) = T:=identity; cas := 0; dlzka := arclength P; mojkrok:=adjust_step(dlzka, 1.0u);
pickup PenC; sideL := (-.20u,0)--(-.20u,0.20u); sideR := (.20u,0)--(.20u,0.20u); rung := (-.20u,0.10u)--(.20u,0.10u);
picture symbol,test_symbol; symbol:= image ( thdraw sideL; thdraw sideR; thdraw rung; );
forever: t := arctime cas of P; thdraw symbol shifted (point t of P) withcolor black; cas := cas + mojkrok; exitif cas > dlzka + (mojkrok / 3); % for rounding errors endfor;
enddef;
_______________________________________________ Therion mailing list Therion@speleo.sk https://mailman.speleo.sk/listinfo/therion