Differences

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

Link to this comparison view

Both sides previous revision Previous revision
metapost [2019/06/04 00:02]
tarquinwj [Magnetic effects]
metapost [2019/06/09 09:25]
brucemutton [Scalebars] Add Scalebar 3
Line 1597: 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: 2 months ago
  • by brucemutton