metapost

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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 slukametapost [2019/06/04 00:02] – [Magnetic effects] tarquinwj
Line 10: Line 10:
 [[http://tex.loria.fr/english/prod-graph.html|Page with many links to Metapost documentation and examples]]\\ [[http://tex.loria.fr/english/prod-graph.html|Page with many links to Metapost documentation and examples]]\\
 [[http://staff.science.uva.nl/~heck/Courses/mptut.pdf|Learning METAPOST by Doing, André Heck]] (pdf)\\ [[http://staff.science.uva.nl/~heck/Courses/mptut.pdf|Learning METAPOST by Doing, André Heck]] (pdf)\\
-[[http://tex.loria.fr/formats/context/metafun-p.pdf|Loria: The Metafun manual, Hans Hagen, 2000]] (pdf)\\ +[[http://tex.loria.fr/formats/context/metafun-p.pdf|Loria: The Metafun manual, Hans Hagen, 2017]] (pdf)\\ 
-or: [[http://www.pragma-ade.com/general/manuals/metafun-p.pdf|Pragma: The Metafun manual, Hans Hagen, 2000]] (pdf)\\+or: [[http://www.pragma-ade.com/general/manuals/metafun-p.pdf|Pragma: The Metafun manual, Hans Hagen, 2017]] (pdf)\\
 [[http://tex.loria.fr/prod-graph/metafun.pdf|Puzzling graphics in METAPOST, Hans Hagen]] (pdf)\\ [[http://tex.loria.fr/prod-graph/metafun.pdf|Puzzling graphics in METAPOST, Hans Hagen]] (pdf)\\
 [[http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html|Many nice examples]]\\ [[http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html|Many nice examples]]\\
 [[http://http://bbs.ctex.org/forum.php?mod=viewthread&tid=16444|Many links from Michio Matsuyama]], but you have to copy the text and open it as html file\\ [[http://http://bbs.ctex.org/forum.php?mod=viewthread&tid=16444|Many links from Michio Matsuyama]], but you have to copy the text and open it as html file\\
 +
 +==== Previewers ====
 +
 +[[http://www.tlhiv.org/mppreview/|Online previewer]]
 [[http://cseweb.ucsd.edu/~s1pan/MEPer/|Java based MetaPost Editor and Previewer (MEPer)]] [[http://cseweb.ucsd.edu/~s1pan/MEPer/|Java based MetaPost Editor and Previewer (MEPer)]]
  
Line 27: Line 31:
   - Adapt the code to work with Therion (Refer to [[http://marcocorvi.altervista.org/caving/tbe/index.htm|section 7.4 of Marco Corvi's Therion by Examples]]), then    - Adapt the code to work with Therion (Refer to [[http://marcocorvi.altervista.org/caving/tbe/index.htm|section 7.4 of Marco Corvi's Therion by Examples]]), then 
   - 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.  It does not create 'curves' or other more sophisticated Metapost entities.\\+A limitation is that pstoedit converts only to polylines. It does not create 'curves' or other more sophisticated Metapost entities. It is enough to create user symbol for a tree for example. \\
 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:[[http://meeting.contextgarden.net/2008/talks/2008-08-22-hartmut-metapost/mptut-context2008.pdf]] You may check the very basic tutorial of Metapost here:[[http://meeting.contextgarden.net/2008/talks/2008-08-22-hartmut-metapost/mptut-context2008.pdf]]
 +
 +
 +===Implementing redefined metapost examples (Bruce Mutton)===
 +[[templates#general_setup|These examples ]] show how redefined symbols like those below can be used, and includes a redefinition of Atlas so that it includes a north arrow on each page, and a redefinition of the continuation symbol so that it displays the associated text.
 +
 ====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 and Positioning====
 On Sun, Feb 7, 2010 Bruce wrote: On Sun, Feb 7, 2010 Bruce wrote:
-> Is u(and vwfor 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' which will be used in pdf for that scale. On average, diameter of point symbols is 1u in the output.+**u** allows nonlinear scaling of symbols depending on scale. The macro initialize assigns a fixed value to 'u' which will be used in pdf for that scale. On average, diameter of point symbols is (or is intended to be) 1u in the output.
  
-**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 ''T:= identity...'' line will need include those keywords and the variables parsed in the symbol ''def'' statement.  A number of the point symbol examples below do not, possibly intentionally preventing those symbols from being aligned, rotated or scaled respectively.
 +
 +  * Symbol coordinates (0u, 0u) are the origin point for that symbol.  This is the place in the symbol drawing that corresponds exactly to the point symbol location that you will draw in a scrap with XTherion. 
 +
 +  * 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 is because we generally want the map symbols to be about ‘u’ in size.  
 +
 +This image is a symbol that has been defined with maximum x and y coordinates, supposedly, of 0.7u, both positive and negative.  The insertion point is at the intersection of the cross hairs, and the pdf has been exported with a rotate value of 15 degrees.  It has been overlaid with some code that highlights the origin and alignment loci, and unit symbol size, u, as described below.
 +
 +{{:metapost:symbol0.7x0.7notaligned.png?200 |Symbol 0.7u x 0.7u.  (0,0) at the intersection of the cross hairs,  pdf exported with rotate value of 15 degrees}}
 +
 +
 +
 +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 ''centre'' The U: variable is depicted by the light blue box.
 +  * 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, respectively.  ie for a symmetrically placed symbol who’s perimeter will just touch the insertion point, set U:=(0.5x symbol width, 0.5x symbol height).
 +
 +  * 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, to avoid unintentional drawing overlaps for aligned symbols.
 +
 +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.  ie the light blue box should enclose the symbol.  That way, an aligned symbol can always leave a pleasing small gap from its insertion point.
 +
 +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.  So I have written some code that you can temporarily place inside a symbol, to get a visual representation of how well placed its origin and alignment loci are with respect to its insertion point, and of its size compared to the nominal default size of u.
 +
 +Here it is inserted into an electric light symbol definition.  The code is between the lines with % % %.  It creates a green insertion point, a red origin point that represents the (0u, 0u) origin of the symbol, a light blue rectangle that represents the loci of the alignment options (left, top-left etc), and a grey unit symbol size. Note that this code requires that T:= ... rotated BEFORE aligned.  If your symbol uses T:= ... aligned BEFORE rotated, then the code needs to be modified slightly.  
 +
 +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 'symbol') and it is just a bit (but probably acceptably) larger than u in size!
 +
 +<code>
 +   def p_u_electriclight (expr pos,theta,sc,al) =
 +      U:=(0.7u, 0.7u);
 +      % Reduce size of the symbol.  The default size is too big.
 +      interim defaultscale:=0.4sc;
 +      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;               %set this to the third parsed variable (ie 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;
 +</code>
 +
 +
 +Here is an example with the above point symbol that has been redefined with three different U: settings, and inserted with ''-align top-right'' On the left, U:=(1.0u, 1.0u) [U/u=1.4], in the centre, U:=(0.7u, 0.7u) [U/u=1.0], on the right, U:=(0.5u, 0.5u) [U/u= 0.7].  Note that the alignment, top-right, is relative to the local coordinate system in the scrap, not necessarily to the output page coordinate system.  In these examples it does match the output page orientation, because the scrap has 'north up'.
 +
 +{{:metapost:symbol0.7x0.7alignedtr-u1_7_5.png?400|}}
 +
 +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.
 +
 +{{:metapost:symbolparameterindicatorsamples.png?400|}}
 +
 +And one last example, using ''point water'', with the above code added, that demonstrates how align is related to scrap coordinates rather than the output coordinates.
 +
 +{{:metapost:symbolscrapaligntooutputalignexplained.png?400|}}
 +
 +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 "u" value, but that causes all symbols to be scaled too.)
 +
 +<code>
 +code metapost
 +  def minimumpen = 0.18pt enddef;
 +  def PenA = pencircle scaled (minimumpen*1/0.35) enddef;
 +  def PenB = pencircle scaled (minimumpen*0.7/0.35) enddef;
 +  def PenC = pencircle scaled (minimumpen*0.5/0.35) enddef;
 +  def PenD = pencircle scaled (minimumpen) enddef;
 +  def PenX = pencircle scaled (minimumpen*1.2/0.35) enddef;
 +endcode
 +</code>
  
 =====General Symbol Examples===== =====General Symbol Examples=====
 For example; centrelines, water, point altitudes\\ For example; centrelines, water, point altitudes\\
-**View whole centerline for underground (Stacho Mudrak)**+====Point Symbols==== 
 +===Define a user point symbol for a stalagmite boss=== 
 +[[http://daveclucas.com|(Dave Clucas 2014)]]\\ 
 +{{:metapost:boss.jpg|}} 
 + 
 +  def p_u_boss (expr pos,theta,sc,al)= 
 +    T:=identity aligned al rotated theta scaled sc shifted pos; 
 +    pickup PenD; 
 +    p := (0.08u,0.25u)..(0,0.29u)..(-0.08u,0.25u); 
 +    q := (0.16u,0.5u)..(0u,0.58u)..(-0.16u,0.5u); 
 +    for i=0 upto 9: 
 +     thdraw p rotated 36i; 
 +     thdraw q rotated 36i; 
 +    endfor 
 +    p := fullcircle scaled 0.15u;  
 +    thdraw p; 
 +  enddef; 
 + 
 +===Define an entrance symbol as a theta inside a diamond===  
 +[[http://daveclucas.com|(Dave Clucas 2014)]]\\  
 +{{:metapost:entrancesymbol.png|}} 
 + 
 + 
 +  def p_entrance_MY (expr pos,theta,sc,al)= 
 +    U:=(.2u,.5u); 
 +    T:=identity aligned al rotated theta scaled sc shifted pos; 
 +    path p; 
 +    p = (-.3u,-.25u) -- (-.2u,-.25u){dir 135} .. (0u, .25u) .. {dir 225}(.2u,-.25u) -- (.3u,-.25u); 
 +    thdraw p withpen PenA; 
 +    thdraw unitsquare scaled u shifted (-0.5u,-0.5u) rotated 45 withpen PenD; 
 +  enddef; 
 + 
 + 
 +===Define a user point symbol for a single large irregular block===   
 +[[http://daveclucas.com|(Dave Clucas 2012)]]\\ 
 + 
 +{{:metapost:block.jpg|}} 
 + def p_u_block(expr pos,theta,sc,al) = 
 +    T:=identity aligned al rotated theta scaled sc shifted pos; 
 +   path p q; 
 +   p := (2.3u,0.9u)--(0.65u,1u)--(-0.9u,0.6u)--(-2.15u,-0.1u)--(-2.35u,-0.25u)--(-2.5u,-0.5u)--(-2u,-0.65u)--(-0.75u,-0.65u)--(0.6u,-0.7u)--(1.1u,-0.5u)--(2.1u,-0.15u)--cycle; 
 +   pickup PenB; 
 +   thdraw p; 
 +   % The following line uses the code from Colour Dependant Visualization of Symbols by Bruce Mutton 
 +    if known colour_block_bg: thfill p withcolor colour_block_bg; else: thfill p withcolor (0.75,0.75,0.75); fi; 
 +   q := (-2.5u,-0.5u)--(-2u,-0.65u)--(-0.75u,-0.65u)--(0.6u,-0.7u)--(1.1u,-0.5u)--(2.1u,-0.15u)--(2.3u,0.9u)--(2.5u,0.7u)--(2.5u,0.5u)--(2.25u,-0.9u)--(1.1u,-1.3u)--(0.5u,-1.5u)--(-0.75u,-1.4u)--(-2u,-1.15u)--(-2.35u,-0.65u)--cycle; 
 +   thdraw q; 
 +   thfill q withcolor(0.6,0.6,0.6); 
 +   pickup PenD; 
 +   path p; 
 +   p := (-2u,-0.65u)--(-1.9u,-1u); 
 +   thdraw p; 
 +   path p; 
 +   p := (0.6u,-0.7u)--(0.5u,-1.3u); 
 +   thdraw p; 
 +   path p; 
 +   p := (2.1u,-0.15u)--(2.3u,-0.4u); 
 +   thdraw p; 
 + enddef; 
 + initsymbol("p_u_block"); 
 + 
 +===Point - Artificial Electric Light===  
 +Bill Gee 
 +  # This code defines an artificial electric light.  Used in tourist sections of a cave. 
 +  # by Bill Gee May 2019 
 +    def p_u_electriclight (expr pos,theta,sc,al) = 
 +      U:=(0.3u, 0.3u); 
 +      % Reduce size of the symbol.  The default size is too big. 
 +      interim defaultscale:=0.4sc; 
 +      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: 
 + 
 +{{:metapost:shell.png?250|}} 
 + 
 +  def p_u_shell (expr pos,theta,sc,al)= 
 +    T:=identity shifted pos; 
 +    pickup PenB; 
 +    numeric turns, radius; 
 +    path ss, cesta; 
 +    pair za, zb; 
 +    turns = 1.55; 
 +    radius = .3u; 
 +    za = ( xpart(origin)+0, ypart(origin)+.1u ) rotated 370 turns; 
 +    zb = ( xpart(origin)+.3u, ypart(origin)+0 ) rotated 360 turns; 
 +    cesta := za--zb; 
 +    ss := (origin for t=1 upto 360 turns: -- dir t scaled t endfor) scaled (radius/turns/360); 
 +    thdraw ss withcolor (0.3); 
 +    thdraw (cesta cutbefore ss) withcolor (0.3); 
 +  enddef; 
 + 
 +===P-hangers that face the right way=== 
 + 
 +The default "anchor" symbol takes up a lot of space. It also resists rotation. This produces a P-hanger icon instead. It respects rotation, so that if the "orientation" arrow points to the right, the P-hanger will point in the chosen direction. In addition, it selects the correct direction to face, so that the loop of the hanger always points down the page. It intentionally has a thinner line pointing into the rock, so that it appears to pierce the wall of the cave (just like a real P-hanger). 
 + 
 +<code> 
 +code metapost 
 +  % a P-hanger 
 +  def p_anchor_MY (expr P,R,S,A)= 
 +    U:=(.25u,.4u); 
 +    T:=identity aligned A rotated R scaled S shifted P; 
 +    % thick part sticking out of the rock 
 +    thdraw (0,0)--(0,.4u) withpen PenB withcolor black; 
 +    % thin part in the rock 
 +    thdraw (0,-.2u)--(0,0) withpen PenC withcolor black; 
 +    % the loop should hang down the "page", based on the rotation 
 +    if (R > 0) and (R < 180): 
 +      Facing:=-1 
 +    else: 
 +      Facing:=1 
 +    fi; 
 +    % stubs to hold the semicircle 
 +    thdraw (0,.1u)--(Facing*.1u,.1u) withpen PenB withcolor black; 
 +    thdraw (0,.4u)--(Facing*.1u,.4u) withpen PenB withcolor black; 
 +    % semicircle 
 +    thdraw halfcircle scaled .3u rotated (Facing*-90) shifted (Facing*.1u,.25u) withpen PenB withcolor black; 
 +  enddef; 
 +  initsymbol("p_anchor_MY"); 
 +endcode 
 +</code> 
 + 
 +{{ ::phanger.png?nolink |}} 
 + 
 +Use it with this line in your layout: 
 + 
 +  symbol-assign point anchor MY 
 + 
 +===Warning triangle=== 
 + 
 +Warning triangle with exclamation mark, and yellow background: 
 + 
 +<code> 
 +code metapost 
 +  % a warning triangle 
 +  def p_u_warning (expr P,R,S,A)= 
 +    scale:=0.5u; 
 +    sin120:=sind(120); 
 +    cos120:=cosd(120); 
 +    U:=(sin120*scale,scale); 
 +    T:=identity aligned A rotated R scaled S shifted P; 
 +    % yellow triangle 
 +    thfill (0,scale)--(sin120*scale,cos120*scale)--(sind(240)*scale,cosd(240)*scale)--cycle withcolor (1,1,0); 
 +    % black triangle outline 
 +    thdraw (0,scale)--(sin120*scale,cos120*scale) withpen PenB withcolor black; 
 +    thdraw (sin120*scale,cos120*scale)--(sind(240)*scale,cosd(240)*scale) withpen PenB withcolor black; 
 +    thdraw (sind(240)*scale,cosd(240)*scale)--(0,scale) withpen PenB withcolor black; 
 +    % line of ! 
 +    thdraw (0,0)--(0,.5*scale) withpen PenB withcolor black; 
 +    thdraw (0,-.25*scale)--(0,-.25*scale) withpen PenB withcolor black; 
 +    % dot of ! 
 +  enddef; 
 +  initsymbol("p_u_warning"); 
 +endcode 
 +</code> 
 + 
 +{{ ::warning.png?nolink |}} 
 + 
 +Select this as point type "u" with "-subtype warning" in its options. Use it with this line in your layout: 
 + 
 +  text en "point u:warning" "warning/danger" 
 + 
 +===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> 
 +code metapost 
 +  % a spinning compass 
 +  def p_u_magnetism (expr P,R,S,A)= 
 +    scale:=0.5u; 
 +    halfline:=(0.5u/20S); %half thickness of PenC - pen thicknesses do not scale with S 
 +    pointheight:=scale*.9; 
 +    pointwidth:=scale*.4; 
 +    U:=(scale,scale); 
 +    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,pointheight)--(pointwidth,0)--(-pointwidth,0)--cycle withcolor black; 
 +    % black triangle outline 
 +    thdraw (0,-pointheight+halfline)--(pointwidth-halfline,0) withpen PenC withcolor black; 
 +    thdraw (0,-pointheight+halfline)--(-pointwidth+halfline,0) withpen PenC withcolor black; 
 +    % spin arcs, a full circle is path 0-8, anticlockwise, starting from the right 
 +    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("p_u_magnetism"); 
 +endcode 
 +</code> 
 + 
 +{{ ::magnetism.png?nolink |}} 
 + 
 +Select this as point type "u" with "-subtype magnetism" in its options. Use it with this line in your layout: 
 + 
 +  text en "point u:magnetism" "magnetism" 
 +====Line Symbols==== 
 +===View whole centerline for underground=== 
 + Stacho Mudrak
  
 If you wish to view whole centerline for underground, just redefine symbol in layout: If you wish to view whole centerline for underground, just redefine symbol in layout:
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://thomas-holder.de|Thomas Holder]] for version 5.2.x...
  
 +// 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:=identity;
 +      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 NZSS line wall presumed===
- +
-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://thomas-holder.de|Thomas Holder]] for version 5.2.x... +
- +
-// 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:=identity; +
-      pickup PenC; +
-      thdraw P dashed evenly scaled (2*optical_zoom); +
-    enddef; +
-    endcode +
- +
-**Code to define NZSS line wall presumed**\\+
 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 NZSS line chimney (aven)**\\+===Define NZSS line chimney (aven)===
  
     code metapost     code metapost
Line 221: Line 520:
     endcode     endcode
          
-**Code to define NZSS line ceiling-step**\\+===Define NZSS line ceiling-step===
 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 NZSS line ceiling-meander**\\+===Define NZSS line ceiling-meander===
 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**  [[http://daveclucas.com|(Dave Clucas 2014)]]\\ +===Draw a plank walk and (rope) handrail===  
-{{:metapost:boss.jpg|}} +[[http://daveclucas.com|(Dave Clucas 2014)]]
- +
-  def p_u_boss (expr pos,theta,sc,al)= +
-    T:=identity aligned al rotated theta scaled sc shifted pos; +
-    pickup PenD; +
-    p :(0.08u,0.25u)..(0,0.29u)..(-0.08u,0.25u); +
-    q := (0.16u,0.5u)..(0u,0.58u)..(-0.16u,0.5u); +
-    for i=0 upto 9: +
-     thdraw p rotated 36i; +
-     thdraw q rotated 36i; +
-    endfor +
-    p := fullcircle scaled 0.15u;  +
-    thdraw p; +
-  enddef; +
- +
-**Code to define an entrance symbol as a theta inside a diamond** [[http://daveclucas.com|(Dave Clucas 2014)]]\\  +
- +
-{{:metapost:entrancesymbol.png|}} +
- +
- +
-  def p_entrance_MY (expr pos,theta,sc,al)= +
-    U:=(.2u,.5u); +
-    T:=identity aligned al rotated theta scaled sc shifted pos; +
-    path p; +
-    p = (-.3u,-.25u) -- (-.2u,-.25u){dir 135} .. (0u, .25u) .. {dir 225}(.2u,-.25u) -- (.3u,-.25u); +
-    thdraw p withpen PenA; +
-    thdraw unitsquare scaled u shifted (-0.5u,-0.5u) rotated 45 withpen PenD; +
-  enddef; +
- +
- +
-**Code to define a user point symbol for a single large irregular block**  [[http://daveclucas.com|(Dave Clucas 2012)]]\\ +
- +
-{{:metapost:block.jpg|}} +
- def p_u_block(expr pos,theta,sc,al) = +
-    T:=identity aligned al rotated theta scaled sc shifted pos; +
-   path p q; +
-   p := (2.3u,0.9u)--(0.65u,1u)--(-0.9u,0.6u)--(-2.15u,-0.1u)--(-2.35u,-0.25u)--(-2.5u,-0.5u)--(-2u,-0.65u)--(-0.75u,-0.65u)--(0.6u,-0.7u)--(1.1u,-0.5u)--(2.1u,-0.15u)--cycle; +
-   pickup PenB; +
-   thdraw p; +
-   % The following line uses the code from Colour Dependant Visualization of Symbols by Bruce Mutton +
-    if known colour_block_bg: thfill p withcolor colour_block_bg; else: thfill p withcolor (0.75,0.75,0.75); fi; +
-   q := (-2.5u,-0.5u)--(-2u,-0.65u)--(-0.75u,-0.65u)--(0.6u,-0.7u)--(1.1u,-0.5u)--(2.1u,-0.15u)--(2.3u,0.9u)--(2.5u,0.7u)--(2.5u,0.5u)--(2.25u,-0.9u)--(1.1u,-1.3u)--(0.5u,-1.5u)--(-0.75u,-1.4u)--(-2u,-1.15u)--(-2.35u,-0.65u)--cycle; +
-   thdraw q; +
-   thfill q withcolor(0.6,0.6,0.6); +
-   pickup PenD; +
-   path p; +
-   p := (-2u,-0.65u)--(-1.9u,-1u); +
-   thdraw p; +
-   path p; +
-   p := (0.6u,-0.7u)--(0.5u,-1.3u); +
-   thdraw p; +
-   path p; +
-   p := (2.1u,-0.15u)--(2.3u,-0.4u); +
-   thdraw p; +
- enddef; +
- initsymbol("p_u_block"); +
- +
- +
-**code to draw a plank walk and (rope) handrail** [[http://daveclucas.com|(Dave Clucas 2014)]]+
  
 {{:metapost:plankwalk.png|}} {{:metapost:plankwalk.png|}}
Line 377: Line 618:
      enddef;      enddef;
  
-**code to define a doline** [[http://daveclucas.com|(Dave Clucas 2014)]]+===Define a doline=== 
 +[[http://daveclucas.com|(Dave Clucas 2014)]]
  
 {{:metapost:doline.png|}} {{:metapost:doline.png|}}
Line 403: Line 645:
     enddef;     enddef;
  
----- +===Define Line Handrail=== 
-----+Andrew Atkinson
  
-=====Cave Symbol Size and Density Examples===== +{{:metapost:rails.png|Rails}} 
-**Modification MetaPost code for NSS (Philip Schuchardt)**+ 
 +  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"
 + 
 +===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:=identity; 
 +        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/3[zz1,zz2]) > 0.1pt) or 
 +             (length(zz4-2/3[zz1,zz2]) > 0.1pt): 
 +            zz5 = whatever[zz1,zz2]; 
 +            (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,zz2]; 
 +            (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; 
 +       
 +{{:metapost:strata.png?250|}} 
 + 
 +===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:=identity; 
 +        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/3[zz1,zz2]) > 0.1pt) or 
 +             (length(zz4-2/3[zz1,zz2]) > 0.1pt): 
 +            zz5 = whatever[zz1,zz2]; 
 +            (zz3-zz5) = whatever * (zz1-zz2) rotated 90; 
 +            draw zz1--zz5 dashed evenly; 
 +            zz6 = whatever[zz1,zz2]; 
 +            (zz4-zz6) = whatever * (zz1-zz2) rotated 90; 
 +            draw zz2--zz6 dashed evenly; 
 +          else: 
 +            draw zz1--zz2 dashed evenly; 
 +          fi; 
 +        endfor; 
 +      enddef; 
 +       
 +{{:metapost:fault.png?250|}} 
 + 
 + 
 +====Area Symbols====  
 +===Show area water in a different color=== 
 +Martin Budaj 
 + 
 +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. 
 + 
 +---- 
 +===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 (Stacho Mudrák)**\\+===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 area AUT sand more spaced out and more random===
 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
 + 
 +     symbol-colour area blocks [67 31 4]
 +
 +     code metapost
 +     def a_blocks (expr p) =
 +       T:=identity;
 +       pickup PenC;
 +       path q, qq; q = bbox p;
 +       picture tmp_pic; 
 +       uu := max(u, (xpart urcorner q - xpart llcorner q)/100, (ypart urcorner q - ypart llcorner q)/100);
 +       tmp_pic := image(
 +         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,-.5uu)--(.5uu,-.5uu)--(.5uu,.5uu)--(-.5uu,.5uu)--cycle) 
 +           randomized (uu/2))
 +                  rotated uniformdeviate(360) 
 +                  shifted ((i,j) randomized 1.6uu);
 +             if xpart (p intersectiontimes qq) < 0:
 +                  thdraw qq;
 +             fi;
 +           endfor;  
 +         endfor;
 +       );
 +       clip tmp_pic to p;
 +       draw tmp_pic;
 +     enddef;
 +This is modified a_blocks_SKBB definition with "thclean qq;" statement removed. Stacho Mudrák
 +
 +== Another solution ==
 +Another solution is to leave "thclean qq" on its original position and change
 +
 +      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
 +
 +{{:metapost:boulder.jpg?300|Boulders shown as produced by default settings}}
 +
 +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("a_blocks_BCA");
 +    
 +    def a_blocks_BCA (expr p) =
 +  T:=identity;
 +  symbol_distance:=0.7; % Distance between the blocks as set out in a rectangular grid
 +  block_randomisation:=0.7; % Max each point of the base block can be moved. Too big and they can intersect themselves
 +  base_rotation:= 0; % Rotation from 0 of base block, can be used to set all blocks to the same angle
 +  random_rotation:= 360; % Rotation either side of base rotation eg 20 will be plus or minus 10 each side
 +  min_scale_factor:=0.7; % Minimum multiplier used for the base shape
 +  add_scale_factor:= 0.6; % Added to the minimum multiplier to get the maximum scale
 +  block_rectangle:=1.5; % How much longer the block is than it is wide, before randomising
 +  shift_randomisation:=0.75; % Max random amount block can be moved from the original grid
 +  %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     llcorner q)/100);
 + 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/sides))*iu/2,(sind(360*n/sides))*uu/2) -- 
 +                             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
 +            exitif xpart (p intersectiontimes qq) < 0;
 +            qq:= qq scaled (0.99 );
 +           endfor;
 +             if pointinside((i,j),p,outside): % Cleans lines on border, assumably ones outside with jut an edge touching
 +                thclean qq;
 +                thclean qq;
 +                thclean qq;
 +                thclean qq;
 +                thdraw qq;
 +             fi;
 +       endfor;  
 +    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
 +
 +{{:metapost:bedding.jpg?300|Bedding breakdown produced with settiing below}}
 +
 +using the settings
 +
 +  symbol_distance:=0.5; % Distance between the blocks as set out in a rectangular grid
 +  block_randomisation:=0.7; % Max each point of the base block can be moved. Too big and they can intersect themselves
 +  base_rotation:= 20; % Rotation from 0 of base block, can be used to set all blocks to the same angle
 +  random_rotation:= 5; % Rotation either side of base rotation eg 20 will be plus or minus 10 each side
 +  min_scale_factor:=0.5; % Minimum multiplier used for the base shape
 +  add_scale_factor:= 0.6; % Added to the minimum multiplier to get the maximum scale
 +  block_rectangle:=7; % How much longer the block is than it is wide, before randomising
 +  shift_randomisation:=0.75; % Max random amount block can be moved from the original grid
 +  %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, 0.73, 0.71, 0.75);
 +
 +      def a_u_lgrey(expr P) =
 +        T:=identity;
 +        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 (Stacho Mudrak)**+===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" (Carlos Grohmann & 
- Martin Budaj) ** 
- 
-    def s_northarrow_SKBB (expr rot) = 
-      T:=identity scaled 0.7 rotated -rot; 
-          begingroup 
-          interim defaultscale:=1; 
-          label(btex Norte Geografico etex, (0,-1cm)); 
-        endgroup; 
-      thdraw (-.5cm,-1cm)--(0,1.5cm)--(.5cm,-1cm)--(0,-.5cm)--cycle; 
-      thfill (-.5cm,-1cm)--(0,1.5cm)--(0,-.5cm)--cycle; 
-    enddef; 
- 
  
-**Altitude Point**\\+===Altitude Point===
 {{:metapost:p_altitude-1.png}} {{:metapost:p_altitude-1.png}}
 from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x... from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x...
Line 758: Line 1268:
     enddef;     enddef;
          
-**To make 'point height' have P prefix for pits and C prefix for climbs (Martin Budaj)**  +===Make 'point height' have P prefix for pits and C prefix for climbs=== 
 +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://article.gmane.org/gmane.comp.gis.therion/933/match=importance+scaling+text+orientation|Forum post describing some labelling issues and how to conditionally print labels]] [[http://article.gmane.org/gmane.comp.gis.therion/933/match=importance+scaling+text+orientation|Forum post describing some labelling issues and how to conditionally print labels]]
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:=1;
 +          label(btex Norte Geografico etex, (0,-1cm));
 +        endgroup;
 +      thdraw (-.5cm,-1cm)--(0,1.5cm)--(.5cm,-1cm)--(0,-.5cm)--cycle;
 +      thfill (-.5cm,-1cm)--(0,1.5cm)--(0,-.5cm)--cycle;
 +    enddef;
 +
 +----
  
-**Northarrow 1** \\+===Northarrow 1===
 {{:metapost:s_northarrow-1.png}} {{:metapost:s_northarrow-1.png}}
 from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x... from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x...
Line 804: Line 1329:
     enddef;     enddef;
  
-**Northarrow 2** \\+===Northarrow 2===
 {{:metapost:s_northarrow-2.png}} {{:metapost:s_northarrow-2.png}}
 from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x... from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x...
Line 825: Line 1350:
     enddef;     enddef;
          
-**Northarrow 3** \\+===Northarrow 3===
 {{:metapost:s_northarrow-3.jpg|}} {{:metapost:s_northarrow-3.jpg|}}
 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:s_northarrow-Ngridmag.png?150|}} {{:metapost:s_northarrow-Ngridmag.png?150|}}
 {{[[metapost|:metapost:s_northarrow-Nmag.png?150|]]}} {{[[metapost|:metapost:s_northarrow-Nmag.png?150|]]}}
Line 923: Line 1448:
   enddef;   enddef;
  
-**Northarrow 4a** \\+===Northarrow 4a===
 {{:metapost:s_northarrow-nmag_date.png?150|}}\\ {{:metapost:s_northarrow-nmag_date.png?150|}}\\
 With actual date\\ With actual date\\
Line 994: Line 1519:
   enddef;   enddef;
  
- +====Scalebars==== 
-**Scalebar 1**\\+===Scalebar 1===
 {{:metapost:s_scalebar-1.png}} {{:metapost:s_scalebar-1.png}}
 from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x... from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x...
Line 1025: Line 1550:
     enddef;     enddef;
  
-**Scalebar 2**\\+===Scalebar 2===
 {{:metapost:s_scalebar-2.png}} {{:metapost:s_scalebar-2.png}}
 from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x... from [[http://thomas-holder.de|Thomas Holder]] for version 5.2.x...
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/10,-tmph)--(-tmpl+0.25*u/10,-tmph);     draw (tmpl-0.25*u/10,-tmph)--(-tmpl+0.25*u/10,-tmph);
  
-**Code to change grid symbols from cross hairs to continuous lines**\\+====Gridlines==== 
 +===Change grid symbols from cross hairs to continuous lines===
 from Stacho Mudrak (mostly) and Bruce Mutton 2007 from Stacho Mudrak (mostly) and Bruce Mutton 2007
  
Line 1271: Line 1797:
 ---- ----
  
-===== Other MetaPost Stuff===== 
- 
- ===Some more metapost examples (Bruce Mutton)=== 
-[[templates#general_setup|These ]] include some similar to the above, a redefinition of Atlas so that it includes a north arrow on each page, and a redefinition of the continuation symbol so that it displays the associated text. 
- 
- 
- 
----- 
----- 
- 
-===== Area blocks with colored rock-borders only (not filled) ===== 
- 
-in case you use similar command:  
-     symbol-colour area blocks [67 31 4] 
- 
-     code metapost 
-     def a_blocks (expr p) = 
-       T:=identity; 
-       pickup PenC; 
-       path q, qq; q = bbox p; 
-       picture tmp_pic;  
-       uu := max(u, (xpart urcorner q - xpart llcorner q)/100, (ypart urcorner q - ypart llcorner q)/100); 
-       tmp_pic := image( 
-         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,-.5uu)--(.5uu,-.5uu)--(.5uu,.5uu)--(-.5uu,.5uu)--cycle)  
-           randomized (uu/2)) 
-                  rotated uniformdeviate(360)  
-                  shifted ((i,j) randomized 1.6uu); 
-             if xpart (p intersectiontimes qq) < 0: 
-                  thdraw qq; 
-             fi; 
-           endfor;   
-         endfor; 
-       ); 
-       clip tmp_pic to p; 
-       draw tmp_pic; 
-     enddef; 
-This is modified a_blocks_SKBB definition with "thclean qq;" statement removed. Stacho Mudrák 
- 
-== Another solution == 
-Another solution is to leave "thclean qq" on its original position and change 
- 
-      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, 0.73, 0.71, 0.75); 
- 
-      def a_u_lgrey(expr P) = 
-        T:=identity; 
-        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:=identity; 
-        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/3[zz1,zz2]) > 0.1pt) or 
-             (length(zz4-2/3[zz1,zz2]) > 0.1pt): 
-            zz5 = whatever[zz1,zz2]; 
-            (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,zz2]; 
-            (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; 
-       
-{{:metapost:strata.png?250|}} 
- 
-===== 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:=identity; 
-        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/3[zz1,zz2]) > 0.1pt) or 
-             (length(zz4-2/3[zz1,zz2]) > 0.1pt): 
-            zz5 = whatever[zz1,zz2]; 
-            (zz3-zz5) = whatever * (zz1-zz2) rotated 90; 
-            draw zz1--zz5 dashed evenly; 
-            zz6 = whatever[zz1,zz2]; 
-            (zz4-zz6) = whatever * (zz1-zz2) rotated 90; 
-            draw zz2--zz6 dashed evenly; 
-          else: 
-            draw zz1--zz2 dashed evenly; 
-          fi; 
-        endfor; 
-      enddef; 
-       
-{{:metapost:fault.png?250|}} 
  • metapost.txt
  • Last modified: 22 months ago
  • by tarquinwj