2.4. Appearance in 2D (1): lines, and Fonts

All the objects in a canvas are to be painted with three tools: lines, fills and fonts. For 3D scenes, when they are rendered with the BREP renderer, they end-up being a canvas, so the same applies. Anableps allows a extremely flexible configuration of the way lines fillings and text are displayed.

Those are objects that are not displayed directly, but used in conjunction with other object to

2.4.1. Line attributes (LineAttrs)

2.4.1.1. Attributes:

  • .thickness: The thickness of the line, given as a length measure in display space.
  • .color: the color for the line. See below how to define colors
  • .dash: dash can be a string with dots and hyphens, or a tuple of numbers with the length of dashes, 0 for a point.
  • .style: the style of the drawn lines. See below
../_images/lineAttrs.png

simple lines with different attributes

2.4.1.1.1. Examples:

.dash (0,2)mm      ## this results in a dash of points 2mm appart
.dash (2,1,0,1)    ## this is a complex dax, dot, line, with 1mm gaps

2.4.2. Line styles

Tracers do not get limited to change thickness or dash of a line. In addition they can modify the shape of the line. There can be zig-zag lines, wiggly lines, etc. This is achieved wsith the .style attribute. Available styles are:

straight:the normal one
wiggly:wigly lines
zigzag:zig-zag lines
square:square outpockets
hairy:line with hairs
pricky:line with spines
hand1:hand-drawn
hand2:hand-drawn in little segments
../_images/line-styles.png

Available line styles (code)

2.4.2.1. Adjusting the style

Style can take several parameters

pitch:the length of the recurring deviations from the straight line.
amplitude:the amplitude of the deviations.

The following example [stylepitch] shows two rectangles with different pitch

rectangle r: .size 20 30 cm : .style wiggly : ..pitch 1cm : ..amplitude 3mm
rectangle s: .as r : .pitch 2cm

Note

line styles are actually unary operators on the objects, so if linestyle is set, the object created will be a styleup object instead.

2.4.2.2. Creating an style

New styles can be created, by providing a class that contains the following functions

  • segment(point1, point2):
  • arc(point1, point2, point3):
  • curve(points):

They should return a list made of segments, arcs, and curves.

This functions will be called for every line drawn, so they can slow considerably the rendering.

Note

Line styles are astethical, and take no part in calculations. For all calculations simple lines are taken into account

2.4.3. Fonts