Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
metapost [2020/09/22 13:35] – New north arrow 5 example added beni | metapost [2024/11/17 06:04] (current) – [Area Symbols] add link to https://colorcodes.io brucemutton | ||
---|---|---|---|
Line 143: | Line 143: | ||
% show U alignment box light blue | % show U alignment box light blue | ||
q:= (xpart U, -ypart U) -- (xpart U, ypart U) -- (-xpart U, ypart U) -- (-xpart U, -ypart U) -- cycle; | q:= (xpart U, -ypart U) -- (xpart U, ypart U) -- (-xpart U, ypart U) -- (-xpart U, -ypart U) -- cycle; | ||
- | thdraw q shifted -(xpart alignment * xpart U, ypart alignment * ypart U) rotated -rotation withpen PenD withcolor 0.5blue+0.5white; | + | thdraw q shifted -(xpart alignment * xpart U, ypart alignment * ypart U) rotated -rotation withpen PenD withcolor 0.5[blue, |
% show u box grey | % show u box grey | ||
- | thdraw unitsquare scaled u shifted (-0.5u, -0.5u) withpen PenD withcolor 0.1black+0.5white; | + | thdraw unitsquare scaled u shifted (-0.5u, -0.5u) withpen PenD withcolor 0.2[black, |
% % % | % % % | ||
| | ||
Line 224: | Line 224: | ||
fi; | fi; | ||
picture thetext; | picture thetext; | ||
- | thetext: | + | thetext: |
if A = (-1,1): | if A = (-1,1): | ||
p_label.ulft(thetext, | p_label.ulft(thetext, | ||
Line 724: | Line 724: | ||
To set the text of the label, use "-attr text 17" in its options. You can also override the styling by using "-attr labelstyle 0" for each point. | To set the text of the label, use "-attr text 17" in its options. You can also override the styling by using "-attr labelstyle 0" for each point. | ||
+ | |||
+ | ===Walking and climbing man in scale on the map=== | ||
+ | |||
+ | From Juraj Halama for Therion 5.5.3 | ||
+ | |||
+ | {{: | ||
+ | |||
+ | picture u_man_c_pic; | ||
+ | u_man_c_pic := image ( | ||
+ | draw (0cm, -0cm) -- (-8cm, 27cm) -- (-36cm, 55cm) -- (-50cm, 99cm) withpen pencircle scaled 16cm; | ||
+ | draw (27cm, 48cm) -- (0, 64cm) -- (-29cm, 61cm) -- (-38cm, 102cm) | ||
+ | draw (-65cm, 48cm) -- (-75cm, 75cm) -- (-53cm, 106cm) -- (0, 106cm) withpen pencircle scaled 14cm; | ||
+ | draw (-44cm, 130cm) withpen pencircle scaled 27cm withcolor black; | ||
+ | ) shifted (20cm, -67cm); | ||
+ | | ||
+ | picture u_man_w_pic; | ||
+ | u_man_w_pic := image ( | ||
+ | draw (0, 0) -- (7.5cm, 36cm) -- (0cm, 69cm) -- (9cm, 99cm) withpen pencircle scaled 16cm; | ||
+ | draw (42cm, 9cm) -- (37.5cm, 42cm) -- (13.5cm, 69cm) -- (30cm, 102cm) withpen pencircle scaled 16cm; | ||
+ | draw (21.5cm, 100.5cm) -- (6.6cm, 69cm) withpen pencircle scaled 16cm; | ||
+ | draw (-24cm, 75cm) -- (-13.5cm, 102cm) -- (9cm, 112.5cm) -- (30cm, 108cm) -- (51cm, 87cm) -- (75cm, 93cm) withpen pencircle scaled 14cm; | ||
+ | draw (30cm, 132cm) withpen pencircle scaled 27cm withcolor black; | ||
+ | ) shifted (-20cm, -70cm); | ||
+ | | ||
+ | def p_u_man_c (expr P, R, S, A) = | ||
+ | U := (60cm, 85cm) scaled (0.01 / Scale); | ||
+ | T:=identity aligned A rotated R scaled S shifted P; | ||
+ | thdraw u_man_c_pic scaled (0.01 / Scale); | ||
+ | enddef; | ||
+ | | ||
+ | def p_u_man_w (expr P, R, S, A) = | ||
+ | U := (60cm, 80cm) scaled (0.01 / Scale); | ||
+ | T:=identity aligned A rotated R scaled S shifted P; | ||
+ | thdraw u_man_w_pic scaled (0.01 / Scale); | ||
+ | enddef; | ||
+ | | ||
+ | def p_u_man_c_legend = | ||
+ | draw u_man_c_pic scaled (u / 175cm) shifted ((.5, .5) inscale); | ||
+ | enddef; | ||
+ | | ||
+ | def p_u_man_w_legend = | ||
+ | draw u_man_w_pic scaled (u / 175cm) shifted ((.5, .5) inscale); | ||
+ | enddef; | ||
+ | | ||
+ | text en "point u: | ||
+ | text en "point u: | ||
+ | |||
+ | Notes: | ||
+ | Use " | ||
+ | Climbing one has center where the rope should go on the harness... | ||
+ | The scale on the map and in the legend is matching just for 1:500... | ||
+ | |||
+ | ===Region names symbol=== | ||
+ | In the Hirlatz cave we use this symbol to tell the name of the adjacent (preview) maps. | ||
+ | It is quite customizable and especially shows a way how to do label boxes. | ||
+ | By default it prints the current surveys name in a white-filled box with rounded corners. | ||
+ | You can adjust it per symbol by giving "-attr <var> < | ||
+ | |||
+ | From Benedikt Hallinger for Therion 6.0.3 | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | # Symbol to denote assigned survey. | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | def p_u_mappe(expr pos, theta, sc, al) = | ||
+ | T:=identity aligned al rotated theta scaled sc shifted pos; | ||
+ | begingroup; | ||
+ | % Basic config | ||
+ | bordersmooth: | ||
+ | bordermargin: | ||
+ | basescale: | ||
+ | fillsize: | ||
+ | if known(ATTR_bordersmooth): | ||
+ | if known(ATTR_bordermargin): | ||
+ | if known(ATTR_basescale): | ||
+ | if known(ATTR_fillsize): | ||
+ | | ||
+ | % GET LABEL TEXT: | ||
+ | string txt; | ||
+ | if known(ATTR_text): | ||
+ | txt := ATTR_text; | ||
+ | else: | ||
+ | txt := ATTR__survey; | ||
+ | fi; | ||
+ | | ||
+ | | ||
+ | % PREPARE LABEL: | ||
+ | lab: | ||
+ | pickup PenA; % border thickness | ||
+ | interim bboxmargin: | ||
+ | | ||
+ | % PREPARE BOX and DRAW BOX BACKGROUND: | ||
+ | % q is the box as drawed, but we fill the place first before drawing | ||
+ | q:=((bbox lab) smoothed bordersmooth) aligned al scaled (sc * basescale) rotated theta shifted pos; | ||
+ | if (fillsize <> -1.0): | ||
+ | % draw extending filled box around symbol | ||
+ | if known(MapBackground): | ||
+ | % from therion versions newer than 6.0.3+3551531+dev (23.11.2021) we use page background | ||
+ | thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale * fillsize) withcolor MapBackground; | ||
+ | else: | ||
+ | thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale * fillsize) withcolor label_fill_color; | ||
+ | fi; | ||
+ | fi; | ||
+ | % the following will draw the actual visible interiour-filling of the box | ||
+ | thfill ((bbox lab) smoothed bordersmooth) scaled (sc * basescale) withcolor label_fill_color; | ||
+ | | ||
+ | % DRAW BOX | ||
+ | draw q; | ||
+ | | ||
+ | % DRAW LABEL TEXT | ||
+ | lab:=lab aligned al; | ||
+ | lab:=lab scaled (sc * basescale); | ||
+ | lab:=lab rotated theta; | ||
+ | lab:=lab shifted pos; | ||
+ | process_label(pos, | ||
+ | endgroup; | ||
+ | enddef; | ||
+ | |||
+ | |||
+ | |||
+ | |||
====Line Symbols==== | ====Line Symbols==== | ||
===View whole centerline for underground=== | ===View whole centerline for underground=== | ||
Line 1011: | Line 1136: | ||
zz3 := postcontrol t of P; | zz3 := postcontrol t of P; | ||
zz4 := precontrol t+1 of P; | zz4 := precontrol t+1 of P; | ||
+ | linecap_prev: | ||
linecap:=0; | linecap:=0; | ||
if (length(zz3-1/ | if (length(zz3-1/ | ||
Line 1032: | Line 1158: | ||
draw zz1--zz2 withcolor background; | draw zz1--zz2 withcolor background; | ||
fi; | fi; | ||
+ | linecap: | ||
endfor; | endfor; | ||
enddef; | enddef; | ||
Line 1570: | Line 1697: | ||
Colors are in order R, G, B --- 0=0 1=255. Color (0.1, 0.2, 0.8) means (25 51 204) in Photoshop - quite dark blue. Light blue could be for example (123 213 255) in Photoshop - it is (123/255, 213/255, 255/255) or (0.48, 0.84 1.0) for Metapost. | Colors are in order R, G, B --- 0=0 1=255. Color (0.1, 0.2, 0.8) means (25 51 204) in Photoshop - quite dark blue. Light blue could be for example (123 213 255) in Photoshop - it is (123/255, 213/255, 255/255) or (0.48, 0.84 1.0) for Metapost. | ||
- | See also [[tips#RGB to Therion Colour Mapping Calculator|this spreadsheet]] to visualise and convert between colour formats. | + | See also |
---- | ---- | ||
Line 2069: | Line 2196: | ||
A: Try this code: | A: Try this code: | ||
- | |||
- | def_transparent_rgb(tr_lgrey, | ||
def a_u_lgrey(expr P) = | def a_u_lgrey(expr P) = | ||
T: | T: | ||
- | thfill P withtransparentcolor tr_lgrey; | + | thfill P withcolor (0.7, 0.7, 0.7) withalpha 0.5; |
enddef; | enddef; | ||
- | There are a few predefined transparent colors, the most interesting of them is tr_bg (current scrap background). Standard opacity value (defined in the layout section) is applied. M. Budaj | ||
---- | ---- | ||
Line 2448: | Line 2572: | ||
{{: | {{: | ||
- | | + | // distributed under the GNU General Public License.// |
code metapost | code metapost | ||
def s_northarrow (expr rot) = | def s_northarrow (expr rot) = | ||
Line 2467: | Line 2592: | ||
label(" | label(" | ||
else: | else: | ||
- | | + | |
fi | fi | ||
endgroup; | endgroup; | ||
Line 2473: | Line 2598: | ||
enddef; | enddef; | ||
endcode | endcode | ||
+ | ===Shaded Compass Rose pointing to the magnetic North=== | ||
+ | from Juraj Halama for version 5.5.3 | ||
+ | |||
+ | {{: | ||
+ | |||
+ | // distributed under the GNU General Public License.// | ||
+ | |||
+ | def s_northarrow (expr rot) = | ||
+ | scale_value = 0.5; | ||
+ | decl := MagDecl; | ||
+ | T := identity; | ||
+ | | ||
+ | picture tmp_pic; | ||
+ | tmp_pic = image ( | ||
+ | pickup pencircle scaled 1; | ||
+ | thdraw fullcircle scaled 4cm; | ||
+ | thdraw fullcircle scaled 2.75cm; | ||
+ | pickup pencircle scaled .5; | ||
+ | thdraw fullcircle scaled 3.75cm; | ||
+ | for whereto=11.25 step 22.5 until 360: | ||
+ | thdraw dir(whereto)*2.75/ | ||
+ | endfor; | ||
+ | % arrows | ||
+ | path halfarrow; | ||
+ | halfarrow = (+.3cm, | ||
+ | for whereto = 45 step 90 until 315: | ||
+ | % thfill halfarrow scaled .85 rotated whereto withcolor .30; | ||
+ | pickup pencircle scaled 1; | ||
+ | for halfarrowgrad = 1 step -.05 until 0: | ||
+ | thdraw ((halfarrowgrad*.3cm, | ||
+ | endfor; | ||
+ | pickup pencircle scaled .5; | ||
+ | thdraw halfarrow scaled .85 rotated whereto;; | ||
+ | thfill halfarrow xscaled -1 scaled .85 rotated whereto withcolor white; | ||
+ | thdraw halfarrow xscaled -1 scaled .85 rotated whereto;; | ||
+ | endfor; | ||
+ | for whereto = 0 step 90 until 270: | ||
+ | % thfill halfarrow scaled 1.15 rotated whereto withcolor .30; | ||
+ | pickup pencircle scaled 1; | ||
+ | for halfarrowgrad = 1 step -.05 until 0: | ||
+ | thdraw ((halfarrowgrad*.3cm, | ||
+ | endfor; | ||
+ | pickup pencircle scaled .5; | ||
+ | thdraw halfarrow scaled 1.15 rotated whereto;; | ||
+ | thfill halfarrow xscaled -1 scaled 1.15 rotated whereto withcolor white; | ||
+ | thdraw halfarrow xscaled -1 scaled 1.15 rotated whereto;; | ||
+ | endfor; | ||
+ | % central circles | ||
+ | thfill fullcircle scaled .56cm withcolor 1white; | ||
+ | pickup pencircle scaled .5; | ||
+ | thdraw fullcircle scaled .56cm; | ||
+ | thfill fullcircle scaled .3cm withcolor .30; | ||
+ | % characters | ||
+ | label.bot(thTEX(" | ||
+ | label.lft(thTEX(" | ||
+ | label.rt (thTEX(" | ||
+ | label.top(thTEX(" | ||
+ | % space among characters | ||
+ | pickup pencircle scaled .5; | ||
+ | thdraw (dir(45)*2cm)--(dir(45)*2.5cm); | ||
+ | thdraw (dir(135)*2cm)--(dir(135)*2.5cm); | ||
+ | thdraw (dir(225)*2cm)--(dir(225)*2.5cm); | ||
+ | thdraw (dir(315)*2cm)--(dir(315)*2.5cm); | ||
+ | ); | ||
+ | | ||
+ | thdraw tmp_pic scaled scale_value rotatedaround (origin, - rot); | ||
+ | enddef; | ||
Line 2535: | Line 2727: | ||
endgroup; | endgroup; | ||
enddef; | enddef; | ||
+ | |||
+ | ===Scalebar 2b=== | ||
+ | By B. Hallinger; This is the same scalebar from above, except that it subdivides the first block. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | code metapost | ||
+ | def s_scalebar (expr l, units, txt) = | ||
+ | % l = value of scale-bar length | ||
+ | % units = ?? | ||
+ | % txt = string representing units | ||
+ | begingroup | ||
+ | interim warningcheck: | ||
+ | tmpl:=l / Scale * cm * units / 2; | ||
+ | % tmpl = half plotted length of scale bar from central top insertion point | ||
+ | tmpx:=l / Scale * cm * units / 5; | ||
+ | tmph:=5bp; % bar height | ||
+ | endgroup; | ||
+ | pickup PenC; | ||
+ | draw (-tmpl, | ||
+ | p: | ||
+ | for i:=-0.5 step 2 until 2: % start drawing at the third block (leave space for smaller divisions) | ||
+ | fill p shifted (i * tmpx,0); | ||
+ | endfor; | ||
+ | | ||
+ | % Draw first part with subdivided blocks | ||
+ | p: | ||
+ | for i:=-2.5 step 2/5 until -0.75: | ||
+ | fill p shifted (i * tmpx,0) withcolor black; | ||
+ | endfor; | ||
+ | | ||
+ | % Label of scale: Scalebar top, values below | ||
+ | begingroup | ||
+ | interim labeloffset: | ||
+ | for i:=0 step (l/5) until (l-1): | ||
+ | tmpx:=tmpl * (i * 2 / l - 1); | ||
+ | label.bot(thTEX(decimal (i)), | ||
+ | endfor; | ||
+ | label.bot(thTEX(decimal (l) & " | ||
+ | label.top(thTEX(" | ||
+ | endgroup; | ||
+ | | ||
+ | enddef; | ||
+ | endcode | ||
+ | |||
===Scalebar Bar length adjustment=== | ===Scalebar Bar length adjustment=== | ||
Line 2601: | Line 2838: | ||
endcode | endcode | ||
endlayout LayoutScalebar3 | endlayout LayoutScalebar3 | ||
+ | | ||
+ | ===Vertical scalebar=== | ||
+ | {{: | ||
+ | by Juraj Halama for version 5.5.3... | ||
+ | |||
+ | // distributed under the GNU General Public License.// | ||
+ | |||
+ | layout mapa_ext_500 | ||
+ | | ||
+ | scale-bar 170 m | ||
+ | % layout for map | ||
+ | copy mapa | ||
+ | overlap 0 cm | ||
+ | | ||
+ | code metapost | ||
+ | | ||
+ | def s_scalebar (expr l, units, txt) = | ||
+ | begingroup | ||
+ | tmpw = 3.0 bp; | ||
+ | tmp5m = 5 / Scale * units * cm; | ||
+ | tmpl = l / Scale * units * cm; | ||
+ | endgroup; | ||
+ | p := (0, 0) -- (tmpw, 0) -- (tmpw, - tmp5m) -- (0, - tmp5m) -- cycle; | ||
+ | pickup PenD; | ||
+ | for i := 0 step 1 until (l - 1) / 5: | ||
+ | if (i mod 2) <> 0: | ||
+ | unfill p shifted - (0, i * tmp5m); | ||
+ | else: | ||
+ | fill p shifted - (0, i * tmp5m); | ||
+ | fi; | ||
+ | draw p shifted - (0, i * tmp5m); | ||
+ | endfor; | ||
+ | pickup PenA | ||
+ | % draw (-tmpw, 0) -- (tmpw, 0); | ||
+ | % draw (-tmpw, -tmpl) -- (0, -tmpl); | ||
+ | fill (-2tmpw, tmpw) -- (-2tmpw, -tmpw) -- (0, 0) -- cycle; | ||
+ | fill (-2tmpw, -tmpl + tmpw) -- (-2tmpw, -tmpl + -tmpw) -- (0, -tmpl) -- cycle; | ||
+ | if ((l mod 10) > 5) or ((l mod 10) = 0): | ||
+ | draw (0, - tmpl) -- (tmpw, - tmpl) withcolor black; | ||
+ | else: | ||
+ | draw (0, - tmpl) -- (tmpw, - tmpl) withcolor white; | ||
+ | fi; | ||
+ | begingroup | ||
+ | interim labeloffset: | ||
+ | % interim defaultscale: | ||
+ | label.rt(thTEX(" | ||
+ | for i := 1 step 1 until l / 5: | ||
+ | if (i mod 10) = 0: | ||
+ | label.rt(thTEX(" | ||
+ | else: | ||
+ | if i * 5 = l: | ||
+ | label.rt(thTEX(" | ||
+ | else: | ||
+ | label.rt(thTEX(" | ||
+ | fi | ||
+ | fi; | ||
+ | endfor; | ||
+ | if (l mod 5) <> 0: | ||
+ | label.rt(thTEX(" | ||
+ | fi; | ||
+ | endgroup | ||
+ | enddef; | ||
+ | |||
+ | endcode | ||
+ | | ||
+ | code tex-map | ||
+ | | ||
+ | \def\maplayout{ | ||
+ | \legendbox{102.5}{100.4}{NW} | ||
+ | { | ||
+ | \scalebar | ||
+ | } | ||
+ | } | ||
+ | endcode | ||
+ | | ||
+ | endlayout | ||
====Gridlines==== | ====Gridlines==== | ||
===Change grid symbols from cross hairs to continuous lines=== | ===Change grid symbols from cross hairs to continuous lines=== | ||
Line 2612: | Line 2925: | ||
) -- ( | ) -- ( | ||
if xpos > 0: 0 else: xsize/2 fi, 0 | if xpos > 0: 0 else: xsize/2 fi, 0 | ||
- | ) withcolor 0.1black+0.5white; | + | ) withcolor 0.2[black, |
draw ( | draw ( | ||
0, if ypos < 0: 0 else: -ysize/2 fi | 0, if ypos < 0: 0 else: -ysize/2 fi | ||
) -- ( | ) -- ( | ||
0, if ypos > 0: 0 else: ysize/2 fi | 0, if ypos > 0: 0 else: ysize/2 fi | ||
- | ) withcolor 0.1black+0.5white; | + | ) withcolor 0.2[black, |
enddef; | enddef; | ||
endcode | endcode | ||
Line 2707: | Line 3020: | ||
thclean Path; | thclean Path; | ||
pickup PenD; | pickup PenD; | ||
- | if known colour_sump_bg: | + | if known colour_sump_bg: |
thfill Path withpattern pattern_sump; | thfill Path withpattern pattern_sump; | ||
%%thdraw Path; %outline, not needed as area drawn is defined by line border anyway | %%thdraw Path; %outline, not needed as area drawn is defined by line border anyway | ||
Line 2722: | Line 3035: | ||
T: | T: | ||
pickup pensquare scaled (1.0*u/10); | pickup pensquare scaled (1.0*u/10); | ||
- | if known colour_rope: | + | if known colour_rope: |
fi; | fi; | ||
pickup PenC; | pickup PenC; | ||
Line 2798: | Line 3111: | ||
Comment it out when you want black and white. | Comment it out when you want black and white. | ||
- | ---- | + | =====Symbols for plan and extended elevation===== |
- | ---- | + | |
+ | Juraj Halama 2020 for Therion 5.5.3\\ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | It is not a regular point due to its size, but all the features of points are working... | ||
+ | |||
+ | def p_u_symbol_plan (expr pos, | ||
+ | U := (-3.25u, 3.25u); | ||
+ | T := identity aligned al rotated theta scaled sc shifted pos; | ||
+ | pickup PenB; | ||
+ | q := ((-3.26u, | ||
+ | | ||
+ | thdraw q; | ||
+ | q := ((-.175u, .5u) -- (0u, 0u) -- (.175u, .5u) .. (0u, .45u) .. cycle); | ||
+ | thfill q withcolor .5green; | ||
+ | thdraw q withcolor .5green; | ||
+ | thdraw (0u, 0u) -- (0u, 2.31u) withcolor .5green; | ||
+ | enddef; | ||
+ | |||
+ | def p_u_symbol_extend (expr pos, | ||
+ | U := (-2.5u, 2.5u); | ||
+ | T := identity aligned al rotated theta scaled sc shifted pos; | ||
+ | pickup PenB; | ||
+ | q := ((-2.346u, -2.480u) -- (-.48u, -2.116u) -- (-.48u, 1.573u) -- (-2.346u, 1.354u) -- cycle); | ||
+ | thfill q withcolor .85; | ||
+ | q := ((-1.551u, -2.878u) -- (1.438u, -.766u) -- (1.438u, 2.388u) -- (-1.551u, 1.118u) -- cycle); | ||
+ | thfill q withcolor .75; | ||
+ | thdraw q; | ||
+ | thdraw (-.48u, -2.116u) -- (-.48u, 1.573u) dashed evenly; | ||
+ | q := ((.446u, -1.461u) -- (2.120u, -1.094u) -- (2.120u, 2.184u) -- (.446u, 1.965u) -- cycle); | ||
+ | thfill q withcolor .85; | ||
+ | thdraw (.446u, -1.461u) -- (.446u, 1.965u) dashed evenly; | ||
+ | q := ((-.175u, .5u) -- (0u, 0u) -- (.175u, .5u) .. (0u, .45u) .. cycle) rotated -90; | ||
+ | thfill q withcolor .5green; | ||
+ | thdraw q withcolor .5green; | ||
+ | thdraw (0u, 0u) -- (2.31u, 0u) withcolor .5green; | ||
+ | enddef; | ||
+ | |||
+ | ...and do not forget to remove it from legend: | ||
+ | |||
+ | text sk "point u: | ||
+ | text sk "point u: | ||