Therion wiki

Differences

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

metapost [2012/06/17 11:39]
sluka typo
metapost [2012/11/24 11:22] (current)
daveclucas
Line 218: Line 218:
  endcode   endcode
         
 +**Code to define a user point symbol for a stalagmite boss**  Dave Clucas 2012\\
 +{{: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;
 +  
 +**Code to define a user point symbol for a single large irregular block**  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");
---- ----
Line 921: Line 963:
 +
 +----
 +----
 +
 +===== 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
---- ----
---- ----
 
metapost.1339925990.txt.gz · Last modified: 2012/06/17 11:39 by sluka