Prev: interpolation.html Up Next: color.html
Length

Practical Guide:
length l1 = 2*CM + width("some text");   // lengths can be linear-combined
length l2 = 2 * !l1 + 3*MM;              // l2 holds a reference (!) to l1...
l1 = LW;                                 // so if l1 changes (here to the LW unit -- linewidth) ..
cerr<<l2<<endl;                          // then l2 also changes. to debug lengths, use the << operator

Lengths are the most important things in blop. When designing this class, the following goals were considered:

To satisfy these considerations, this class has become rather abstract. It does not hold a specific numerical value (like 2.34 of some units), but for example it can be set to be "the width of the string 'temperature'". How much this is exactly, depends on the terminal (for example, a blopeps terminal typesets text with the current font of the LaTeX document, where it will be included, so at this point it is principally impossible to know, how much this width is). From this follows, that two lengths can not be compared (unfortunately). So you can not write:

length l1 = width("some text");
length l2 = 2*CM + EX;
if(l1 < l2) { .... }
else        { .... }

The following ways exist to create lengths:


Lengths are thus rather abstract objects, and they have to be specialized for a given terminal, before they can be used in this terminal. This is not done by the user, and he never has to worry about this, but it also belongs to the picture. Skip this part if you don't want to go too deeply into the details. Lengths are specialized when a canvas is printed to a terminal (see examples elsewhere), and what this process means, can be best explained with an example: let a be a length, which is the width of the string "hello". As stated above, this object (when created), does not hold any more information, just this: I am the width of the strig "hello". The width of the string "hello", however, can be different in different terminals, and specializing this lengths means asking the terminal to calculate (in its own, hidden way) the width of this string. The terminal will store this information privately, and return an integer (a length ID), which refers to this piece of information. When lengths are specialized (calling their length::specialize(terminal *) member function), they store this ID returned by the terminal, and later all graphical manipulations (drawing a line from this point to that point, drawing a text at this or that coordinate) will use this ID to refer to the given length.

Source files:
   length.h
   length.cc

Prev: interpolation.html Up Next: color.html