Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
metapost [2018/05/16 10:32] – add link to very basic tutorial sluka | metapost [2019/06/04 00:02] – [Magnetic effects] tarquinwj | ||
---|---|---|---|
Line 10: | Line 10: | ||
[[http:// | [[http:// | ||
[[http:// | [[http:// | ||
- | [[http:// | + | [[http:// |
- | or: [[http:// | + | or: [[http:// |
[[http:// | [[http:// | ||
[[http:// | [[http:// | ||
[[http:// | [[http:// | ||
+ | |||
+ | ==== Previewers ==== | ||
+ | |||
+ | [[http:// | ||
[[http:// | [[http:// | ||
Line 27: | Line 31: | ||
- Adapt the code to work with Therion (Refer to [[http:// | - Adapt the code to work with Therion (Refer to [[http:// | ||
- Compile a test map and admire your work. | - Compile a test map and admire your work. | ||
- | A limitation is that pstoedit converts only to polylines. | + | A limitation is that pstoedit converts only to polylines. It does not create ' |
Another way is to draw your symbol on graph paper and then create Metapost code for straight or smooth curved lines. | Another way is to draw your symbol on graph paper and then create Metapost code for straight or smooth curved lines. | ||
Both approaches will in due course require you to learn some Metapost!\\ | Both approaches will in due course require you to learn some Metapost!\\ | ||
You may check the very basic tutorial of Metapost here: | You may check the very basic tutorial of Metapost here: | ||
+ | |||
+ | |||
+ | ===Implementing redefined metapost examples (Bruce Mutton)=== | ||
+ | [[templates# | ||
+ | |||
====How to get Therions MetaPost code (and Tex code)==== | ====How to get Therions MetaPost code (and Tex code)==== | ||
Line 65: | Line 74: | ||
---- | ---- | ||
- | ====Symbol Sizing==== | + | ====Symbol Sizing |
On Sun, Feb 7, 2010 Bruce wrote: | On Sun, Feb 7, 2010 Bruce wrote: | ||
- | > Is u: (and v: w: for that matter) intended to correspond to a | + | > Is u (and v w for that matter) intended to correspond to a |
> particular drawn entity size in the finished pdf, or are they just | > particular drawn entity size in the finished pdf, or are they just | ||
> arbitrary variables for which one can calculate the value of, using | > arbitrary variables for which one can calculate the value of, using | ||
Line 73: | Line 82: | ||
> Bruce | > Bruce | ||
- | **u** allows nonlinear scaling of symbols depending on scale. The macro initialize assigns a fixed value to ' | + | **u** allows nonlinear scaling of symbols depending on scale. The macro initialize assigns a fixed value to ' |
- | **v** and **w** behave differently (v could be used e.g. for some area fills with decreasing distance among symbols for smaller scales but only up to a certain threshold, then bigger distance again; w is almost constant). Currently they are not (or perhaps only occasionaly) used in symbols design. | + | **v** and **w** behave differently (v could be used e.g. for some area fills with decreasing distance among symbols for smaller scales but only up to a certain threshold, then bigger distance again; w is almost constant). Currently they are not (or perhaps only occasionally) used in symbols design. |
In the beginning we wanted to do some sort of optimization of values assigned to u, v, w but did not manage to do it so far. It would be useful if somebody could test alternative values (and alternative breaks for map scale in the initialize macro) for various scales and various styles of map drawing (lot of symbols vs. sparsely filled map). Good setup of these values could improve map appearance substantially. | In the beginning we wanted to do some sort of optimization of values assigned to u, v, w but did not manage to do it so far. It would be useful if somebody could test alternative values (and alternative breaks for map scale in the initialize macro) for various scales and various styles of map drawing (lot of symbols vs. sparsely filled map). Good setup of these values could improve map appearance substantially. | ||
Line 83: | Line 92: | ||
---- | ---- | ||
+ | |||
+ | Refer to the section **New Map Symbols**, **Point Symbols** in The Therion Book. | ||
+ | |||
+ | If you want your custom point symbol to be able to be aligned, rotated or scaled by users according to options set in th2 drawing files, then your '' | ||
+ | |||
+ | * Symbol coordinates (0u, 0u) are the origin point for that symbol. | ||
+ | |||
+ | * Your symbols should generally be defined so that they fit within the size range -0.5u to +0.5u in both x and y axes, although you can use larger or smaller values in either dimension. | ||
+ | |||
+ | This image is a symbol that has been defined with maximum x and y coordinates, | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | |||
+ | The symbol alignment option relies on the definition of a U: variable, otherwise your symbol will cause an error and stop Therion if a user sets an alignment option other than '' | ||
+ | * U: is a scaling factor for alignment parameters, such as right, top or top-right. | ||
+ | U: defines the size of the x horizontal (left-right) and y vertical (up-down) offset when a symbol is aligned, so the x and y components of U: should be set to be around the maximum absolute value of x and y symbol coordinates, | ||
+ | |||
+ | * If a U: component is smaller than a maximum corresponding symbol coordinate, an aligned symbol will overlap the insertion point. | ||
+ | * If a U: component is larger than a maximum corresponding symbol coordinate, an aligned symbol will have a gap from the insertion point. | ||
+ | * If your symbol has its greatest dimension on a diagonal, then you should increase the U: components accordingly, | ||
+ | |||
+ | As one 'use case' for aligning symbols is to enable them to be placed ‘near’ to another symbol, and be always positioned appropriately at a variety of output scales, I am going to suggest that U: components for user friendly point symbols should always be just a little greater than half the symbol dimension. | ||
+ | |||
+ | When writing a new point symbol and testing that it aligns and rotates nicely, it can be a bit tricky to figure out where the origin, insertion point, and alignment loci are located. | ||
+ | |||
+ | Here it is inserted into an electric light symbol definition. | ||
+ | |||
+ | After writing the code, I realised that this symbol was in fact larger than 0.7u in the y direction, therefore the U: variable is not tall enough, the symbol is not centered around around its (0u,0u) coordinates (which might be OK if you want the space below the luminaire to be part of the ' | ||
+ | |||
+ | < | ||
+ | def p_u_electriclight (expr pos, | ||
+ | U:=(0.7u, 0.7u); | ||
+ | % Reduce size of the symbol. | ||
+ | interim defaultscale: | ||
+ | T:=identity rotated theta aligned al scaled defaultscale shifted pos; %corrected to rotate THEN align | ||
+ | | ||
+ | % % % SYMBOL PARAMETER INDICATOR (origin, insertion, alignment box, u box) | ||
+ | % Placing this code directly after T:= identity line will put the indicators under the symbol | ||
+ | % Placing this code immediately before enddef will put the indicators over top of the symbol | ||
+ | % Before use you need to correctly assign the parsed variable aliases in the next two rows from the def statement above | ||
+ | rotation:= theta; | ||
+ | pair alignment; alignment:= al; %set this to the last parsed variable (ie al) | ||
+ | | ||
+ | % show symbol origin, (0,0) red | ||
+ | thdraw fullcircle scaled 0.15u withpen PenD withcolor red; | ||
+ | % show symbol insertion point, (0,0) green | ||
+ | thdraw fullcircle shifted -(xpart alignment * xpart U, ypart alignment * ypart U) rotated -rotation withpen PenD withcolor green; | ||
+ | % show U alignment box light blue | ||
+ | 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; | ||
+ | % show u box grey | ||
+ | thdraw unitsquare scaled u shifted (-0.5u, -0.5u) withpen PenD withcolor 0.1black+0.5white; | ||
+ | % % % | ||
+ | | ||
+ | pickup PenC; | ||
+ | thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); | ||
+ | thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); | ||
+ | thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); | ||
+ | thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); | ||
+ | thdraw (0.5u,0.0u) -- (0.5u, -0.6u); | ||
+ | thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); | ||
+ | enddef; | ||
+ | </ | ||
+ | |||
+ | |||
+ | Here is an example with the above point symbol that has been redefined with three different U: settings, and inserted with '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | The smudgy line is intended to represent an object that the alignment is intended to avoid, ie a wall. You can see that U: = symbol dimension is OK, but U:= smaller than symbol dimension is probably what most users would want to avoid. | ||
+ | |||
+ | I'm going to suggest that the best values for U: components are between [U/u=1.0] to [U/u=1.2] | ||
+ | |||
+ | An here are some examples with a slightly improved U: variable, with the symbol aligned top-left and oriented 30 degrees, and the output rotated 15, 105, 195, 285 degrees. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | And one last example, using '' | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Bruce | ||
+ | |||
+ | =====Setting pen thicknesses===== | ||
+ | |||
+ | This can be used to set a minimum pen thickness, so that all other pens take their sizes relative to that pen thickness. This can be useful for publications that mandate a specific pen width, which can be harder to control with scaling. (This can be done by setting the " | ||
+ | |||
+ | < | ||
+ | code metapost | ||
+ | def minimumpen = 0.18pt enddef; | ||
+ | def PenA = pencircle scaled (minimumpen*1/ | ||
+ | def PenB = pencircle scaled (minimumpen*0.7/ | ||
+ | def PenC = pencircle scaled (minimumpen*0.5/ | ||
+ | def PenD = pencircle scaled (minimumpen) enddef; | ||
+ | def PenX = pencircle scaled (minimumpen*1.2/ | ||
+ | endcode | ||
+ | </ | ||
=====General Symbol Examples===== | =====General Symbol Examples===== | ||
For example; centrelines, | For example; centrelines, | ||
- | **View whole centerline for underground | + | ====Point Symbols==== |
+ | ===Define a user point symbol for a stalagmite boss=== | ||
+ | [[http:// | ||
+ | {{: | ||
+ | |||
+ | def p_u_boss (expr pos, | ||
+ | T:=identity aligned al rotated theta scaled sc shifted pos; | ||
+ | pickup PenD; | ||
+ | p := (0.08u, | ||
+ | q := (0.16u, | ||
+ | for i=0 upto 9: | ||
+ | | ||
+ | | ||
+ | endfor | ||
+ | p := fullcircle scaled 0.15u; | ||
+ | thdraw p; | ||
+ | enddef; | ||
+ | |||
+ | ===Define an entrance symbol as a theta inside a diamond=== | ||
+ | [[http:// | ||
+ | {{: | ||
+ | |||
+ | |||
+ | def p_entrance_MY (expr pos, | ||
+ | U: | ||
+ | T:=identity aligned al rotated theta scaled sc shifted pos; | ||
+ | path p; | ||
+ | p = (-.3u, | ||
+ | thdraw p withpen PenA; | ||
+ | thdraw unitsquare scaled u shifted (-0.5u, | ||
+ | enddef; | ||
+ | |||
+ | |||
+ | ===Define a user point symbol for a single large irregular block=== | ||
+ | [[http:// | ||
+ | |||
+ | {{: | ||
+ | def p_u_block(expr pos, | ||
+ | T:=identity aligned al rotated theta scaled sc shifted pos; | ||
+ | path p q; | ||
+ | p := (2.3u, | ||
+ | pickup PenB; | ||
+ | thdraw p; | ||
+ | % The following line uses the code from Colour Dependant Visualization of Symbols by Bruce Mutton | ||
+ | if known colour_block_bg: | ||
+ | q := (-2.5u, | ||
+ | thdraw q; | ||
+ | thfill q withcolor(0.6, | ||
+ | pickup PenD; | ||
+ | path p; | ||
+ | p := (-2u, | ||
+ | thdraw p; | ||
+ | path p; | ||
+ | p := (0.6u, | ||
+ | thdraw p; | ||
+ | path p; | ||
+ | p := (2.1u, | ||
+ | thdraw p; | ||
+ | enddef; | ||
+ | initsymbol(" | ||
+ | |||
+ | ===Point - Artificial Electric Light=== | ||
+ | Bill Gee | ||
+ | # This code defines an artificial electric light. | ||
+ | # by Bill Gee May 2019 | ||
+ | def p_u_electriclight (expr pos, | ||
+ | U:=(0.3u, 0.3u); | ||
+ | % Reduce size of the symbol. | ||
+ | interim defaultscale: | ||
+ | T:=identity aligned al rotated theta scaled defaultscale shifted pos; | ||
+ | pickup PenC; | ||
+ | |||
+ | thdraw fullcircle scaled 0.5u shifted (0.0u, 0.7u); | ||
+ | thdraw (-0.5u, -0.6u) -- (-0.5u, 0.0u); | ||
+ | thdraw (-0.5u, 0.0u) .. (-0.35u, 0.55u) .. (0.0u, 0.7u); | ||
+ | thdraw (0.0u, 0.7u) .. (0.35u, 0.55u) .. (0.5u, 0.0u); | ||
+ | thdraw (0.5u,0.0u) -- (0.5u, -0.6u); | ||
+ | thdraw (-0.7u, -0.6u) -- (0.7u, -0.6u); | ||
+ | |||
+ | enddef; | ||
+ | ---- | ||
+ | |||
+ | ===Shell limestone=== | ||
+ | Point symbol for shell limestone: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | def p_u_shell (expr pos, | ||
+ | T:=identity shifted pos; | ||
+ | pickup PenB; | ||
+ | numeric turns, radius; | ||
+ | path ss, cesta; | ||
+ | pair za, zb; | ||
+ | turns = 1.55; | ||
+ | radius = .3u; | ||
+ | za = ( xpart(origin)+0, | ||
+ | zb = ( xpart(origin)+.3u, | ||
+ | cesta := za--zb; | ||
+ | ss := (origin for t=1 upto 360 turns: -- dir t scaled t endfor) scaled (radius/ | ||
+ | thdraw ss withcolor (0.3); | ||
+ | thdraw (cesta cutbefore ss) withcolor (0.3); | ||
+ | enddef; | ||
+ | |||
+ | ===P-hangers that face the right way=== | ||
+ | |||
+ | The default " | ||
+ | |||
+ | < | ||
+ | code metapost | ||
+ | % a P-hanger | ||
+ | def p_anchor_MY (expr P,R,S,A)= | ||
+ | U: | ||
+ | T:=identity aligned A rotated R scaled S shifted P; | ||
+ | % thick part sticking out of the rock | ||
+ | thdraw (0, | ||
+ | % thin part in the rock | ||
+ | thdraw (0, | ||
+ | % the loop should hang down the " | ||
+ | if (R > 0) and (R < 180): | ||
+ | Facing: | ||
+ | else: | ||
+ | Facing:=1 | ||
+ | fi; | ||
+ | % stubs to hold the semicircle | ||
+ | thdraw (0, | ||
+ | thdraw (0, | ||
+ | % semicircle | ||
+ | thdraw halfcircle scaled .3u rotated (Facing*-90) shifted (Facing*.1u, | ||
+ | enddef; | ||
+ | initsymbol(" | ||
+ | endcode | ||
+ | </ | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | Use it with this line in your layout: | ||
+ | |||
+ | symbol-assign point anchor MY | ||
+ | |||
+ | ===Warning triangle=== | ||
+ | |||
+ | Warning triangle with exclamation mark, and yellow background: | ||
+ | |||
+ | < | ||
+ | code metapost | ||
+ | % a warning triangle | ||
+ | def p_u_warning (expr P,R,S,A)= | ||
+ | scale: | ||
+ | sin120: | ||
+ | cos120: | ||
+ | U: | ||
+ | T:=identity aligned A rotated R scaled S shifted P; | ||
+ | % yellow triangle | ||
+ | thfill (0, | ||
+ | % black triangle outline | ||
+ | thdraw (0, | ||
+ | thdraw (sin120*scale, | ||
+ | thdraw (sind(240)*scale, | ||
+ | % line of ! | ||
+ | thdraw (0, | ||
+ | thdraw (0, | ||
+ | % dot of ! | ||
+ | enddef; | ||
+ | initsymbol(" | ||
+ | endcode | ||
+ | </ | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | Select this as point type " | ||
+ | |||
+ | text en "point u: | ||
+ | |||
+ | ===Magnetic effects=== | ||
+ | |||
+ | Certain rocks can cause a compass to give the wrong reading. This icon can be used to show areas where this happens (ie. where the survey may be unreliable as a result); a spinning compass: | ||
+ | |||
+ | < | ||
+ | code metapost | ||
+ | % a spinning compass | ||
+ | def p_u_magnetism (expr P,R,S,A)= | ||
+ | scale: | ||
+ | halfline: | ||
+ | pointheight: | ||
+ | pointwidth: | ||
+ | U: | ||
+ | T:=identity aligned A rotated (R-20) scaled S shifted P; | ||
+ | % a circle | ||
+ | thdraw fullcircle scaled 2scale withpen PenC withcolor black; | ||
+ | % filled triangle | ||
+ | thfill (0, | ||
+ | % black triangle outline | ||
+ | thdraw (0, | ||
+ | thdraw (0, | ||
+ | % spin arcs, a full circle is path 0-8, anticlockwise, | ||
+ | thdraw subpath (2.4,3.5) of fullcircle scaled 1.5scale withpen PenC withcolor black; | ||
+ | thdraw subpath (6.4,7.5) of fullcircle scaled 1.5scale withpen PenC withcolor black; | ||
+ | enddef; | ||
+ | initsymbol(" | ||
+ | endcode | ||
+ | </ | ||
+ | |||
+ | {{ :: | ||
+ | |||
+ | Select this as point type " | ||
+ | |||
+ | text en "point u: | ||
+ | ====Line Symbols==== | ||
+ | ===View whole centerline for underground=== | ||
+ | Stacho Mudrak | ||
If you wish to view whole centerline for underground, | If you wish to view whole centerline for underground, | ||
Line 93: | Line 410: | ||
let l_survey_cave = l_survey_surface_SKBB; | let l_survey_cave = l_survey_surface_SKBB; | ||
endcode | endcode | ||
+ | ---- | ||
+ | ===Green colored continuous centerline=== | ||
+ | from [[http:// | ||
+ | // distributed under the GNU General Public License.// | ||
+ | def l_survey_cave (expr p) = | ||
+ | pickup PenC; | ||
+ | draw p withcolor 0.5green; | ||
+ | enddef; | ||
+ | |||
+ | ===Make unsurveyed wall lines light-weight and dashed=== | ||
+ | A sample of how it looks is in the 'line rope' example below. | ||
+ | |||
+ | code metapost | ||
+ | %Bruce Mutton 2010.06.20 for Therion 5.3.9 | ||
+ | def l_wall_unsurveyed (expr P) = | ||
+ | T: | ||
+ | pickup PenC; | ||
+ | thdraw P dashed evenly scaled (2*optical_zoom); | ||
+ | enddef; | ||
+ | endcode | ||
---- | ---- | ||
- | **Visualize cave centreline shot flags with colour for splay and duplicate, and dash for approximate shot flags** | + | ===Visualize cave centreline shot flags with colour for splay and duplicate, and dash for approximate shot flags=== |
For version 5.3.12+ Dec2013 (Bruce Mutton) | For version 5.3.12+ Dec2013 (Bruce Mutton) | ||
Line 129: | Line 466: | ||
enddef; | enddef; | ||
| | ||
- | |||
---- | ---- | ||
- | **How to show area water in a different color (Martin Budaj)** | + | ===Define |
- | + | ||
- | Add in layout: | + | |
- | + | ||
- | code metapost | + | |
- | def a_water (expr p) = | + | |
- | T:=identity; | + | |
- | thfill p withcolor (0.1, 0.2, 0.8); | + | |
- | enddef; | + | |
- | endcode | + | |
- | + | ||
- | 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. | + | |
- | + | ||
- | + | ||
- | **Green colored continuous centerline** | + | |
- | from [[http:// | + | |
- | + | ||
- | // distributed under the GNU General Public License.// | + | |
- | def l_survey_cave (expr p) = | + | |
- | pickup PenC; | + | |
- | draw p withcolor 0.5green; | + | |
- | enddef; | + | |
- | + | ||
- | **Code to make unsurveyed wall lines light-weight and dashed**\\ | + | |
- | A sample of how it looks is in the 'line rope' example below. | + | |
- | + | ||
- | code metapost | + | |
- | %Bruce Mutton 2010.06.20 for Therion 5.3.9 | + | |
- | def l_wall_unsurveyed (expr P) = | + | |
- | T: | + | |
- | pickup PenC; | + | |
- | thdraw P dashed evenly scaled (2*optical_zoom); | + | |
- | enddef; | + | |
- | endcode | + | |
- | + | ||
- | **Code to define | + | |
Draws dashes with v shaped tick marks outside the passage like we tend to do in New Zealand...\\ | Draws dashes with v shaped tick marks outside the passage like we tend to do in New Zealand...\\ | ||
A sample of how it looks is in the 'line rope' example below. | A sample of how it looks is in the 'line rope' example below. | ||
Line 197: | Line 496: | ||
- | **Code to define | + | ===Define |
code metapost | code metapost | ||
Line 221: | Line 520: | ||
endcode | endcode | ||
| | ||
- | **Code to define | + | ===Define |
This is just Therions default SKBB ceiling step, reflected so that it matches the UIS convention with the tick marks pointing away from the void space. | This is just Therions default SKBB ceiling step, reflected so that it matches the UIS convention with the tick marks pointing away from the void space. | ||
Line 245: | Line 544: | ||
endcode | endcode | ||
- | **Code to define | + | ===Define |
This is just Therions default SKBB ceiling meander, with the symbols reflected so that it matches the UIS convention with the tick marks pointing away from the void space. | This is just Therions default SKBB ceiling meander, with the symbols reflected so that it matches the UIS convention with the tick marks pointing away from the void space. | ||
Line 279: | Line 578: | ||
endcode | endcode | ||
| | ||
- | **Code to define a user point symbol for a stalagmite boss** | + | ===Draw a plank walk and (rope) handrail=== |
- | {{: | + | [[http:// |
- | + | ||
- | def p_u_boss (expr pos, | + | |
- | T:=identity aligned al rotated theta scaled sc shifted pos; | + | |
- | pickup PenD; | + | |
- | p := (0.08u, | + | |
- | q := (0.16u, | + | |
- | for i=0 upto 9: | + | |
- | | + | |
- | | + | |
- | endfor | + | |
- | p := fullcircle scaled 0.15u; | + | |
- | thdraw p; | + | |
- | enddef; | + | |
- | + | ||
- | **Code to define an entrance symbol as a theta inside a diamond** [[http:// | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | + | ||
- | def p_entrance_MY (expr pos, | + | |
- | U: | + | |
- | T:=identity aligned al rotated theta scaled sc shifted pos; | + | |
- | path p; | + | |
- | p = (-.3u, | + | |
- | thdraw p withpen PenA; | + | |
- | thdraw unitsquare scaled u shifted (-0.5u, | + | |
- | enddef; | + | |
- | + | ||
- | + | ||
- | **Code to define a user point symbol for a single large irregular block** | + | |
- | + | ||
- | {{: | + | |
- | def p_u_block(expr pos, | + | |
- | T:=identity aligned al rotated theta scaled sc shifted pos; | + | |
- | path p q; | + | |
- | p := (2.3u, | + | |
- | pickup PenB; | + | |
- | thdraw p; | + | |
- | % The following line uses the code from Colour Dependant Visualization of Symbols by Bruce Mutton | + | |
- | if known colour_block_bg: | + | |
- | q := (-2.5u, | + | |
- | thdraw q; | + | |
- | thfill q withcolor(0.6, | + | |
- | pickup PenD; | + | |
- | path p; | + | |
- | p := (-2u, | + | |
- | thdraw p; | + | |
- | path p; | + | |
- | p := (0.6u, | + | |
- | thdraw p; | + | |
- | path p; | + | |
- | p := (2.1u, | + | |
- | thdraw p; | + | |
- | enddef; | + | |
- | initsymbol(" | + | |
- | + | ||
- | + | ||
- | **code to draw a plank walk and (rope) handrail** [[http:// | + | |
{{: | {{: | ||
Line 377: | Line 618: | ||
| | ||
- | **code to define | + | ===Define |
+ | [[http:// | ||
{{: | {{: | ||
Line 403: | Line 645: | ||
enddef; | enddef; | ||
- | ---- | + | ===Define Line Handrail=== |
- | ---- | + | Andrew Atkinson |
- | =====Cave Symbol Size and Density Examples===== | + | {{: |
- | **Modification MetaPost code for NSS (Philip Schuchardt)** | + | |
+ | def l_u_rail (expr P) = | ||
+ | T:=identity; | ||
+ | cas := 0; | ||
+ | dlzka := arclength P; | ||
+ | mojkrok:=adjust_step(dlzka, | ||
+ | pickup PenC; | ||
+ | forever: | ||
+ | t0 := arctime (cas) of P; | ||
+ | t1 := arctime (cas + mojkrok*2/ | ||
+ | t := arctime (cas + mojkrok/2) of P; | ||
+ | t4 := arctime (cas + mojkrok*3/ | ||
+ | t5 := arctime (cas + mojkrok) of P; | ||
+ | | ||
+ | thdraw (subpath (t4,t5) of P); | ||
+ | drawdot | ||
+ | | ||
+ | #mark_ (P, | ||
+ | #mark_ (P, | ||
+ | #f := (P, | ||
+ | #draw f; | ||
+ | cas := cas + mojkrok; | ||
+ | exitif cas > dlzka - (2*mojkrok/3); % for rounding errors | ||
+ | endfor; | ||
+ | enddef; | ||
+ | initsymbol(" | ||
+ | |||
+ | ===Strata=== | ||
+ | Line symbol for strata for cross sections. It works exactly as line section symbol but you should use -clip off option: | ||
+ | |||
+ | def l_u_strata (expr P) = | ||
+ | T: | ||
+ | path Q; Q = punked P; | ||
+ | for t = 0 upto length P - 1: | ||
+ | pair zz[]; | ||
+ | zz1 := point t of P; | ||
+ | zz2 := point t+1 of P; | ||
+ | zz3 := postcontrol t of P; | ||
+ | zz4 := precontrol t+1 of P; | ||
+ | linecap: | ||
+ | if (length(zz3-1/ | ||
+ | | ||
+ | zz5 = whatever[zz1, | ||
+ | (zz3-zz5) = whatever | ||
+ | pickup pencircle scaled 1 mm; | ||
+ | draw zz1--zz5 dashed evenly; | ||
+ | pickup PenA; | ||
+ | draw zz1--zz5 withcolor background; | ||
+ | zz6 = whatever[zz1, | ||
+ | (zz4-zz6) = whatever * (zz1-zz2) rotated 90; | ||
+ | pickup pencircle scaled 1 mm; | ||
+ | draw zz2--zz6 dashed evenly; | ||
+ | pickup PenA; | ||
+ | draw zz2--zz6 withcolor background; | ||
+ | else: | ||
+ | pickup pencircle scaled 1 mm; | ||
+ | draw zz1--zz2 dashed evenly; | ||
+ | pickup PenA; | ||
+ | draw zz1--zz2 withcolor background; | ||
+ | fi; | ||
+ | endfor; | ||
+ | enddef; | ||
+ | |||
+ | {{: | ||
+ | |||
+ | ===Fault=== | ||
+ | Line symbol for fault. It works exactly as line section symbol but you should use -clip off option: | ||
+ | |||
+ | def l_u_fault (expr P) = | ||
+ | T: | ||
+ | path Q; Q = punked P; | ||
+ | pickup PenA; | ||
+ | for t = 0 upto length P - 1: | ||
+ | pair zz[]; | ||
+ | zz1 := point t of P; | ||
+ | zz2 := point t+1 of P; | ||
+ | zz3 := postcontrol t of P; | ||
+ | zz4 := precontrol t+1 of P; | ||
+ | if (length(zz3-1/ | ||
+ | | ||
+ | zz5 = whatever[zz1, | ||
+ | (zz3-zz5) = whatever * (zz1-zz2) rotated 90; | ||
+ | draw zz1--zz5 dashed evenly; | ||
+ | zz6 = whatever[zz1, | ||
+ | (zz4-zz6) = whatever * (zz1-zz2) rotated 90; | ||
+ | draw zz2--zz6 dashed evenly; | ||
+ | else: | ||
+ | draw zz1--zz2 dashed evenly; | ||
+ | fi; | ||
+ | endfor; | ||
+ | enddef; | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | ====Area Symbols==== | ||
+ | ===Show area water in a different color=== | ||
+ | Martin Budaj | ||
+ | |||
+ | Add in layout: | ||
+ | |||
+ | code metapost | ||
+ | def a_water (expr p) = | ||
+ | T: | ||
+ | thfill p withcolor (0.1, 0.2, 0.8); | ||
+ | enddef; | ||
+ | endcode | ||
+ | |||
+ | 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. | ||
+ | |||
+ | ---- | ||
+ | ===Modification MetaPost code for NSS (Philip Schuchardt)=== | ||
This is how you overload metapost symbols: | This is how you overload metapost symbols: | ||
Line 518: | Line 873: | ||
---- | ---- | ||
- | **Modification of fill densities | + | ===Modification of fill densities=== |
+ | Stacho Mudrák | ||
code metapost | code metapost | ||
Line 563: | Line 919: | ||
---- | ---- | ||
- | **POINT BLOCK +size adjust (symbolsize) Stefan Oswald** | + | ===POINT BLOCK +size adjust (symbolsize)=== |
+ | Stefan Oswald | ||
code metapost | code metapost | ||
Line 579: | Line 936: | ||
---- | ---- | ||
- | **AREA BLOCK + density adjust (distance) Stefan Oswald** | + | ===AREA BLOCK + density adjust (distance)=== |
+ | Stefan Oswald | ||
code metapost | code metapost | ||
Line 608: | Line 966: | ||
endcode | endcode | ||
- | **Code to make area AUT sand more spaced out and more random**\\ | + | ===Make |
A sample of how it looks is in the 'area point colour water' example below. | A sample of how it looks is in the 'area point colour water' example below. | ||
Line 637: | Line 995: | ||
enddef; | enddef; | ||
endcode | endcode | ||
+ | |||
+ | ---- | ||
+ | ===Area blocks with colored rock-borders only (not filled)=== | ||
+ | Martin Budaj | ||
+ | |||
+ | | ||
+ | |||
+ | code metapost | ||
+ | def a_blocks (expr p) = | ||
+ | | ||
+ | | ||
+ | path q, qq; q = bbox p; | ||
+ | | ||
+ | uu := max(u, (xpart urcorner q - xpart llcorner q)/100, (ypart urcorner q - ypart llcorner q)/100); | ||
+ | | ||
+ | for i = xpart llcorner q step 2uu until xpart urcorner q: | ||
+ | for j = ypart llcorner q step 2uu until ypart urcorner q: | ||
+ | qq := punked (((-.5uu, | ||
+ | randomized (uu/2)) | ||
+ | rotated uniformdeviate(360) | ||
+ | shifted ((i,j) randomized 1.6uu); | ||
+ | if xpart (p intersectiontimes qq) < 0: | ||
+ | thdraw qq; | ||
+ | fi; | ||
+ | | ||
+ | | ||
+ | ); | ||
+ | clip tmp_pic to p; | ||
+ | draw tmp_pic; | ||
+ | | ||
+ | This is modified a_blocks_SKBB definition with " | ||
+ | |||
+ | == Another solution == | ||
+ | Another solution is to leave " | ||
+ | |||
+ | clip tmp_pic to p; | ||
+ | draw tmp_pic; | ||
+ | |||
+ | to | ||
+ | |||
+ | clip tmp_pic to p; | ||
+ | drawoptions(); | ||
+ | draw tmp_pic; | ||
+ | |||
+ | at the end of the macro definition. This approach preserves filling the blocks with a background colour. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===Customisable Area Blocks with Different Number of Sides=== | ||
+ | Andrew Atkinson | ||
+ | |||
+ | {{: | ||
+ | |||
+ | Blocks shown as produced by default settings, at about half scale. | ||
+ | |||
+ | Various things could be improved, the drawing of the different sided boulders, and calling of thclean qq; three times to stop transparency cannot be the best way. | ||
+ | |||
+ | **Code for blocks, Variables can be amended at the start** | ||
+ | initsymbol(" | ||
+ | | ||
+ | def a_blocks_BCA (expr p) = | ||
+ | T: | ||
+ | symbol_distance: | ||
+ | block_randomisation: | ||
+ | base_rotation: | ||
+ | random_rotation: | ||
+ | min_scale_factor: | ||
+ | add_scale_factor: | ||
+ | block_rectangle: | ||
+ | shift_randomisation: | ||
+ | %Now set the proportions of different sided block | ||
+ | b_tri:=1; | ||
+ | b_quad:=3; | ||
+ | b_pent:=4; | ||
+ | b_hex:=2; | ||
+ | pickup PenC; | ||
+ | path q, regular, qq; q = bbox p; | ||
+ | pair outside; | ||
+ | outside:= ulcorner q + up; | ||
+ | picture tmp_pic; | ||
+ | uu := max(u, (xpart urcorner q - xpart llcorner q)/100, (ypart urcorner q - ypart | ||
+ | iu := uu * block_rectangle; | ||
+ | blocks := b_tri+b_quad + b_pent + b_hex; | ||
+ | tmp_pic := image( | ||
+ | for i = xpart llcorner q step symbol_distance * block_rectangle * uu until xpart urcorner q: | ||
+ | for j = ypart llcorner q step symbol_distance*uu until ypart urcorner q: | ||
+ | pick_sides := uniformdeviate(blocks); | ||
+ | if pick_sides < b_tri: | ||
+ | sides:=3; | ||
+ | elseif pick_sides < b_tri + b_quad: | ||
+ | sides:=4; | ||
+ | elseif pick_sides < b_tri + b_quad +b_pent: | ||
+ | sides:=5; | ||
+ | else: | ||
+ | sides:=6 | ||
+ | fi; | ||
+ | | ||
+ | qq := for n:=0 upto sides-1: | ||
+ | ((cosd(360*n/ | ||
+ | endfor cycle; %radius is 0.5 divide by 2 | ||
+ | qq := punked ((qq) | ||
+ | randomized (block_randomisation * uu)) | ||
+ | scaled (uniformdeviate(add_scale_factor)+min_scale_factor) | ||
+ | rotated (base_rotation + random_rotation / 2 - uniformdeviate(random_rotation) ) | ||
+ | shifted ((i,j) randomized (shift_randomisation * uu)); | ||
+ | |||
+ | |||
+ | forever: % Repeatedly reduces the size of the image, as this is done round zero it also moves it to the zero location, until it fits in the area | ||
+ | | ||
+ | qq:= qq scaled (0.99 ); | ||
+ | endfor; | ||
+ | if pointinside((i, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | fi; | ||
+ | endfor; | ||
+ | | ||
+ | ); | ||
+ | clip tmp_pic to p; | ||
+ | drawoptions(); | ||
+ | draw tmp_pic; | ||
+ | enddef; | ||
+ | |||
+ | The base_rotation is an attempt to produce bedding plane breakdown, it could do with more time but this is possible | ||
+ | |||
+ | {{: | ||
+ | |||
+ | using the settings | ||
+ | |||
+ | symbol_distance: | ||
+ | block_randomisation: | ||
+ | base_rotation: | ||
+ | random_rotation: | ||
+ | min_scale_factor: | ||
+ | add_scale_factor: | ||
+ | block_rectangle: | ||
+ | shift_randomisation: | ||
+ | %Now set the propotions of different sided block | ||
+ | b_tri:=1; | ||
+ | b_quad:=2; | ||
+ | b_pent:=4; | ||
+ | b_hex:=7; | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ---- | ||
+ | |||
+ | ===Transparent area=== | ||
+ | |||
+ | Q: Is there an additionally possibility to make this definition so that the area will be a bit transparent? | ||
+ | |||
+ | A: Try this code: | ||
+ | |||
+ | def_transparent_rgb(tr_lgrey, | ||
+ | |||
+ | def a_u_lgrey(expr P) = | ||
+ | T: | ||
+ | thfill P withtransparentcolor tr_lgrey; | ||
+ | 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 | ||
---- | ---- | ||
---- | ---- | ||
- | =====Label and Text Examples===== | + | ====Label and Text Examples==== |
- | **To make the debug station names smaller | + | ===To make the debug station names smaller=== |
+ | Stacho Mudrak | ||
Currently, there is no easy way to do this, but it is possible. You just need to | Currently, there is no easy way to do this, but it is possible. You just need to | ||
Line 687: | Line 1210: | ||
... and this line tells metapost to use font size 4 for station names.\\ | ... and this line tells metapost to use font size 4 for station names.\\ | ||
\\ | \\ | ||
- | **I want my north arrow to have a label, like "Norte Geografico" | ||
- | | ||
- | |||
- | def s_northarrow_SKBB (expr rot) = | ||
- | T:=identity scaled 0.7 rotated -rot; | ||
- | begingroup | ||
- | interim defaultscale: | ||
- | label(btex Norte Geografico etex, (0,-1cm)); | ||
- | endgroup; | ||
- | thdraw (-.5cm, | ||
- | thfill (-.5cm, | ||
- | enddef; | ||
- | |||
- | **Altitude Point**\\ | + | ===Altitude Point=== |
{{: | {{: | ||
from [[http:// | from [[http:// | ||
Line 758: | Line 1268: | ||
enddef; | enddef; | ||
| | ||
- | **To make 'point height' | + | ===Make |
+ | Martin Budaj | ||
You just need to add following to your layout: | You just need to add following to your layout: | ||
Line 769: | Line 1280: | ||
| | ||
| | ||
- | **Conditional Printing of Text Labels**\\ | + | ===Conditional Printing of Text Labels=== |
[[http:// | [[http:// | ||
Line 780: | Line 1291: | ||
=====Special Symbol Examples===== | =====Special Symbol Examples===== | ||
Examples of North arrows, scale-bars, gridlines etc\\ | Examples of North arrows, scale-bars, gridlines etc\\ | ||
+ | ====North Arrows==== | ||
+ | ===I want my north arrow to have a label, like "Norte Geografico" | ||
+ | Carlos Grohmann & Martin Budaj | ||
+ | def s_northarrow_SKBB (expr rot) = | ||
+ | T:=identity scaled 0.7 rotated -rot; | ||
+ | begingroup | ||
+ | interim defaultscale: | ||
+ | label(btex Norte Geografico etex, (0,-1cm)); | ||
+ | endgroup; | ||
+ | thdraw (-.5cm, | ||
+ | thfill (-.5cm, | ||
+ | enddef; | ||
+ | |||
+ | ---- | ||
- | **Northarrow 1** \\ | + | ===Northarrow 1=== |
{{: | {{: | ||
from [[http:// | from [[http:// | ||
Line 804: | Line 1329: | ||
enddef; | enddef; | ||
- | **Northarrow 2** \\ | + | ===Northarrow 2=== |
{{: | {{: | ||
from [[http:// | from [[http:// | ||
Line 825: | Line 1350: | ||
enddef; | enddef; | ||
| | ||
- | **Northarrow 3** \\ | + | ===Northarrow 3=== |
{{: | {{: | ||
from Stacho Mudrák for version 5.3.x... | from Stacho Mudrák for version 5.3.x... | ||
Line 847: | Line 1372: | ||
enddef; | enddef; | ||
- | **Northarrow 4** \\ | + | ===Northarrow 4=== |
{{: | {{: | ||
{{[[metapost|: | {{[[metapost|: | ||
Line 923: | Line 1448: | ||
enddef; | enddef; | ||
- | **Northarrow 4a** \\ | + | ===Northarrow 4a=== |
{{: | {{: | ||
With actual date\\ | With actual date\\ | ||
Line 994: | Line 1519: | ||
enddef; | enddef; | ||
- | + | ====Scalebars==== | |
- | **Scalebar 1**\\ | + | ===Scalebar 1=== |
{{: | {{: | ||
from [[http:// | from [[http:// | ||
Line 1025: | Line 1550: | ||
enddef; | enddef; | ||
- | **Scalebar 2**\\ | + | ===Scalebar 2=== |
{{: | {{: | ||
from [[http:// | from [[http:// | ||
Line 1055: | Line 1580: | ||
enddef; | enddef; | ||
- | **Scalebar Bar length adjustment**\\ | + | ===Scalebar Bar length adjustment=== |
from Andrew Atkinson | from Andrew Atkinson | ||
Line 1072: | Line 1597: | ||
draw (tmpl-0.25*u/ | draw (tmpl-0.25*u/ | ||
- | **Code to change | + | ====Gridlines==== |
+ | ===Change | ||
from Stacho Mudrak (mostly) and Bruce Mutton 2007 | from Stacho Mudrak (mostly) and Bruce Mutton 2007 | ||
Line 1271: | Line 1797: | ||
---- | ---- | ||
- | ===== Other MetaPost Stuff===== | ||
- | |||
- | | ||
- | [[templates# | ||
- | |||
- | |||
- | |||
- | ---- | ||
- | ---- | ||
- | |||
- | ===== Area blocks with colored rock-borders only (not filled) ===== | ||
- | |||
- | in case you use similar command: | ||
- | | ||
- | |||
- | code metapost | ||
- | def a_blocks (expr p) = | ||
- | | ||
- | | ||
- | path q, qq; q = bbox p; | ||
- | | ||
- | uu := max(u, (xpart urcorner q - xpart llcorner q)/100, (ypart urcorner q - ypart llcorner q)/100); | ||
- | | ||
- | for i = xpart llcorner q step 2uu until xpart urcorner q: | ||
- | for j = ypart llcorner q step 2uu until ypart urcorner q: | ||
- | qq := punked (((-.5uu, | ||
- | randomized (uu/2)) | ||
- | rotated uniformdeviate(360) | ||
- | shifted ((i,j) randomized 1.6uu); | ||
- | if xpart (p intersectiontimes qq) < 0: | ||
- | thdraw qq; | ||
- | fi; | ||
- | | ||
- | | ||
- | ); | ||
- | clip tmp_pic to p; | ||
- | draw tmp_pic; | ||
- | | ||
- | This is modified a_blocks_SKBB definition with " | ||
- | |||
- | == Another solution == | ||
- | Another solution is to leave " | ||
- | |||
- | clip tmp_pic to p; | ||
- | draw tmp_pic; | ||
- | |||
- | to | ||
- | |||
- | clip tmp_pic to p; | ||
- | drawoptions(); | ||
- | draw tmp_pic; | ||
- | |||
- | at the end of the macro definition. This approach preserves filling the blocks with a background colour. Martin Budaj | ||
- | |||
- | |||
- | |||
- | ---- | ||
- | ---- | ||
- | |||
- | ===== Transparent area ===== | ||
- | |||
- | Q: Is there an additionally possibility to make this definition so that the area will be a bit transparent? | ||
- | |||
- | A: Try this code: | ||
- | |||
- | def_transparent_rgb(tr_lgrey, | ||
- | |||
- | def a_u_lgrey(expr P) = | ||
- | T: | ||
- | thfill P withtransparentcolor tr_lgrey; | ||
- | 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 | ||
- | |||
- | ---- | ||
- | ---- | ||
- | |||
- | ===== Strata ===== | ||
- | Line symbol for strata for cross sections. It works exactly as line section symbol but you should use -clip off option: | ||
- | |||
- | def l_u_strata (expr P) = | ||
- | T: | ||
- | path Q; Q = punked P; | ||
- | for t = 0 upto length P - 1: | ||
- | pair zz[]; | ||
- | zz1 := point t of P; | ||
- | zz2 := point t+1 of P; | ||
- | zz3 := postcontrol t of P; | ||
- | zz4 := precontrol t+1 of P; | ||
- | linecap:=0; | ||
- | if (length(zz3-1/ | ||
- | | ||
- | zz5 = whatever[zz1, | ||
- | (zz3-zz5) = whatever * (zz1-zz2) rotated 90; | ||
- | pickup pencircle scaled 1 mm; | ||
- | draw zz1--zz5 dashed evenly; | ||
- | pickup PenA; | ||
- | draw zz1--zz5 withcolor background; | ||
- | zz6 = whatever[zz1, | ||
- | (zz4-zz6) = whatever * (zz1-zz2) rotated 90; | ||
- | pickup pencircle scaled 1 mm; | ||
- | draw zz2--zz6 dashed evenly; | ||
- | pickup PenA; | ||
- | draw zz2--zz6 withcolor background; | ||
- | else: | ||
- | pickup pencircle scaled 1 mm; | ||
- | draw zz1--zz2 dashed evenly; | ||
- | pickup PenA; | ||
- | draw zz1--zz2 withcolor background; | ||
- | fi; | ||
- | endfor; | ||
- | enddef; | ||
- | | ||
- | {{: | ||
- | |||
- | ===== Fault ===== | ||
- | Line symbol for fault. It works exactly as line section symbol but you should use -clip off option: | ||
- | |||
- | def l_u_fault (expr P) = | ||
- | T: | ||
- | path Q; Q = punked P; | ||
- | pickup PenA; | ||
- | for t = 0 upto length P - 1: | ||
- | pair zz[]; | ||
- | zz1 := point t of P; | ||
- | zz2 := point t+1 of P; | ||
- | zz3 := postcontrol t of P; | ||
- | zz4 := precontrol t+1 of P; | ||
- | if (length(zz3-1/ | ||
- | | ||
- | zz5 = whatever[zz1, | ||
- | (zz3-zz5) = whatever * (zz1-zz2) rotated 90; | ||
- | draw zz1--zz5 dashed evenly; | ||
- | zz6 = whatever[zz1, | ||
- | (zz4-zz6) = whatever * (zz1-zz2) rotated 90; | ||
- | draw zz2--zz6 dashed evenly; | ||
- | else: | ||
- | draw zz1--zz2 dashed evenly; | ||
- | fi; | ||
- | endfor; | ||
- | enddef; | ||
- | | ||
- | {{: |