Besides elementary drawing operations for lines, polygons, and circles, CindyScript also offers the possibility to combine these objects into more complicated objects called shapes. Shapes are not directly visible, but may be used for filling, outline drawing or clipping. They can be combined using logical operations like union, intersection or set difference. We first list the elementary operators and then explain their usage in a more elaborate example.
A circular shape:
This operator creates a circular shape of a given
around a given
A polygonal shape:
This operator creates a polygonal shape defined by a list of positions given in
A half-plane shape:
This operator creates a half-plane shape. The half-plane is defined by its supporting line
and a point
contained in the half-plane, which determines on which side of the supporting line the half-plane lies.
may either be a three-dimensional vector of homogeneous coordinates, or a reference to a line object.
The shape of the screen:
This operator creates a rectangular shape that is large enough to cover all active drawing surfaces.
Primitive shapes can be combined to form new shapes using three logical operators.
| creates the union of two shapes
| creates the intersection of two shapes
| creates the difference of two shapes
Shapes can be used for filling, outline drawing and clipping.
Fill a shape:
This operator fills a shape with a specified color.
This operator supports the following modifiers:
|sets the fill color to an RGB value
|sets the opacity to the value |
Draw a shape:
This operator draws the outline of a shape.
This operator is a further polymorphic extension to the usual draw operator and supports the same modifiers.
This operator sets the clip path to the given shape. All subsequent drawing operations are clipped with respect to this clip path. The clip path is pushed on the appearance stack, thus it can be removed again by statements like
The following examples illustrate the use of shapes. The following code defines three different shapes, a quadratic one and two circular ones. These are then combined into a more complex shape using logical operations. The complex shape is filled and outlined. The original shapes are outlined by a thinner line.
The resulting image is shown as the first picture below. The other three images are created using other combinations of the shapes.
The following code snippet demonstrates the usage of shapes as a clipping path. First of all, four circles and their union are defined as a shape. Then this shape is used as a clipping path for another drawing (concentric circles around point E
Shapes can become rather complicated objects, as the following iterative example shows. A word of caution may be appropriate here: The more complicated shape become, the more computational resources they consume. The use of overly complex shapes can slow down Cinderella considerably.