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 [2019/06/02 23:21] – [Symbol Sizing and Positioning] clarify symbol parameter indicator brucemuttonmetapost [2019/06/09 09:25] – [Scalebars] Add Scalebar 3 brucemutton
Line 159: Line 159:
  
  
-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].  Notice that the alignment, top-right, is relative to the local coordinate system in the scrap, not to the output page coordinate system.+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|}} {{:metapost:symbol0.7x0.7alignedtr-u1_7_5.png?400|}}
Line 166: Line 166:
  
 I'm going to suggest that the best values for U: components are between [U/u=1.0] to [U/u=1.2] 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 Bruce
Line 358: Line 366:
  
   text en "point u:warning" "warning/danger"   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==== ====Line Symbols====
 ===View whole centerline for underground=== ===View whole centerline for underground===
Line 1555: 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);
  
 +===Scalebar 3===
 +{{:metapost:scalebar3.png?=400}}  by Chris Hayes
 +
 +  layout LayoutScalebar3 # Scalebar by Chris Hayes
 + code metapost
 + def s_scalebar (expr l, units, txt) =
 +   begingroup
 + interim warningcheck:=0;
 + tmp05:=5 * (l / Scale * cm * units / 100);
 + tmp10:=10 * (l / Scale * cm * units / 100);
 + tmp20:=20 * (l / Scale * cm * units / 100);
 + tmp40:=40 * (l / Scale * cm * units / 100);
 + tmp60:=60 * (l / Scale * cm * units / 100);
 + tmp80:=80 * (l / Scale * cm * units / 100);
 + tmp100:=100 * (l / Scale * cm * units / 100);
 + scal05:=5 * l / 100;
 + scal10:=10 * l / 100;
 + scal20:=20 * l / 100;
 + scal40:=40 * l / 100;
 + scal60:=60 * l / 100;
 + scal80:=80 * l / 100;
 + brht:= 5bp;
 + lblht:= 8bp;
 +   endgroup;
 +   pickup PenC;
 +   draw (0,0)--(0,brht)--(tmp100,brht)--(tmp100,0)--(0,0);
 +   draw (tmp05,0)--(tmp05,brht);
 +   draw (tmp10,0)--(tmp10,brht);
 +   draw (tmp20,0)--(tmp20,brht);
 +   draw (tmp40,0)--(tmp40,brht);
 +   draw (tmp60,0)--(tmp60,brht);
 +   draw (tmp80,0)--(tmp80,brht);
 +   fill (tmp05,0)--(tmp10,0)--(tmp10,brht)--(tmp05,brht)--cycle;
 +   fill (tmp20,0)--(tmp40,0)--(tmp40,brht)--(tmp20,brht)--cycle;
 +   fill (tmp60,0)--(tmp80,0)--(tmp80,brht)--(tmp60,brht)--cycle;
 +   begingroup
 + label.top(thTEX(decimal (l) & "\thinspace" & txt),origin+(tmp100,lblht));
 + label.top(thTEX(decimal (scal80)),origin+(tmp80,lblht));
 + label.top(thTEX(decimal (scal60)),origin+(tmp60,lblht));
 + label.top(thTEX(decimal (scal40)),origin+(tmp40,lblht));
 + label.top(thTEX(decimal (scal20)),origin+(tmp20,lblht));
 + label.top(thTEX(decimal (scal10)),origin+(tmp10,lblht));
 + label.top(thTEX(decimal (scal05)),origin+(tmp05,lblht));
 + label.top(thTEX(decimal (0)),origin+(0,lblht));
 +   endgroup
 + enddef;    
 + endcode
 +  endlayout LayoutScalebar3
 ====Gridlines==== ====Gridlines====
 ===Change grid symbols from cross hairs to continuous lines=== ===Change grid symbols from cross hairs to continuous lines===
  • metapost.txt
  • Last modified: 22 months ago
  • by tarquinwj