mmj:4

Where we may find the original definitions of symbols?

On web pages therion.speleo.sk/download.php is possible to download the source code of program Therion
(the *.tar.gz file. Windows users might need to use something like 7-zip to extract these).

(An alternative method of obtaining the code is described on the metapost page)

After downloading and uncompressing find the folder therion / mpost.

In this folder you will find files thArea, thLine, thPoint, etc. Each file contains the definitions od symbols for particular group of them: thLine - line symbols, thArea - definitions of areas, thPoint - point symbols.

Each definition starts with keyword def and end with keyword enddef; If we are looking for the definition of line symbol type slope we will find it in file thLine under name l_slope_SKBB where first character means group of symbol - in our example the line, next word means the type of symbol - slope and last group of characters is not important in this case - we may ignore it. The final name for our layout will be l_slope. we shoul copy all the code which is in the block def - enddef

   def a_slope_SKBB (.....)
     ....
     ....
   enddef

into layout section of thconfig between code metapost - endcode keywords. We change the name to a_slope and we may modify the necessary parameters. The best way to find the suitable value is to make several experiments.

Example 1 - modification of array type debris

In section of Metapost code we paste next code:

   def a_debris (expr p) =
   T:=identity;
   % thclean p;
   pickup PenC;
   path q; q = bbox p;
   picture tmp_pic;
   tmp_pic := image(
   for i = xpart llcorner q step 1u until xpart urcorner q:
     for j = ypart llcorner q step 1u until ypart urcorner q:
      draw ((-.2u,0)--(.2u,0))
      rotated uniformdeviate(360)
      shifted ((i,j) randomized 0.6u) withpen PenC;
     endfor;
   endfor;
  );
  clip tmp_pic to p;
  draw tmp_pic;
  enddef;

This code will generate the identical nonmodified symbol. We must modify the code first to modify the final symbol.

We change 3 values in next lines:

   for i = xpart llcorner q step 1u until xpart urcorner q:
   for j = ypart llcorner q step 1u until ypart urcorner q:
   shifted ((i,j) randomized 0.6u) withpen PenC;

Value 1u and 06.u we cjange into:

   for i = xpart llcorner q step 0.7u until xpart urcorner q:
   for j = ypart llcorner q step 0.7u until ypart urcorner q:
   shifted ((i,j) randomized 0.4u) withpen PenC;

What we did? First two lines “say” to compiler that the symbols should be generated not as far from themselfs, third line “says” they should be more randomised.

Here is an exaple of modified layout section in file thconfig.

    source homolak
    layout homolak
        #resolution of final map
        scale 1 100
        #color of final map.
        color map-bg 85 # dle barvy [100 100 100]
        #color by altitude
        #color map-fg altitude
        transparency on
        opacity 90
        # names of persons which surveyed the cave will be added how much they surveyed
        statistics topo-length on
        # the language of legends in map
        language cz
        #show the legend
        legend on
        map-header 8 100 e
        #type of used symbol sets SKBB/UIS/ASF/CCNP
        #symbol-set SKBB
        #to show the names of surveying points 
        debug station-names
        #setup of grid
        grid bottom
        grid-size 10 10 10 m
        #rotation of map
        #rotate 30
        #symbol-assign point station UIS
        #symbol-hide point station
        #don't generate any symbol
        #symbol-hide group all
        #don't generate point section symbol
        #symbol-hide point section
        #generate line wall symbol
        #symbol-show line wall
        #generate line survey symbol
        #symbol-show line survey
        #don't generate line flowstone symbol
        #symbol-hide line flowstone
   code metapost
   def a_debris (expr p) =
   T:=identity;
   % thclean p;
   pickup PenC;
   path q; q = bbox p;
   picture tmp_pic;
   tmp_pic := image(
   for i = xpart llcorner q step 1u until xpart urcorner q:
     for j = ypart llcorner q step 1u until ypart urcorner q:
      draw ((-.2u,0)--(.2u,0))
      rotated uniformdeviate(360)
      shifted ((i,j) randomized 0.6u) withpen PenC;
     endfor;
   endfor;
  );
  clip tmp_pic to p;
  draw tmp_pic;
  enddef;
  endcode
    endlayout
    export map -output output/homolak.pdf -layout homolak

How it looks on map

without modified Metapost code

:czsk:mmj:bez_layout.jpg

with modified Metapost code

:czsk:mmj:layout.jpg

Example 2 - modification of array type blocks

We paste into Metapost code section next code:

    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 2.0uu until xpart urcorner q:
      for j = ypart llcorner q step 2.0uu 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:
        thclean qq;
        thdraw qq;
       fi;
      endfor;
     endfor;
   );
   clip tmp_pic to p;
   draw tmp_pic;
   enddef;

We will change following lines:

   for i = xpart llcorner q step 2.0uu until xpart urcorner q:
   for j = ypart llcorner q step 2.0uu until ypart urcorner q:
   shifted ((i,j) randomized 1.6uu);

We change values 2.0uu and 1.6uu to:

   for i = xpart llcorner q step 1.0uu until xpart urcorner q:
   for j = ypart llcorner q step 1.0uu until ypart urcorner q:
   shifted ((i,j) randomized 1.0uu);

What we did? As in first example first two lines “say” to compiler that the symbols should be generated not as far from themselfs, third line “says” they should be more randomised.

Warning

If the Therion generates an error in time of compilation you made the mistake in modification of code or you used too small values. Increase modified values and try to generate map again. There could be a typo in modified definition - in that case erase the modified definition and paste the original definition into layout and make the modifications again..

Final words

I'll add another modified symbol definitions I made into this chapter..

Don't hesitate and write into Therion conference if you have any question.

Jan Balcařík 18/10/2006 12:29

  • mmj/4.txt
  • Last modified: 13 years ago
  • by brucemutton