Tick
Martin McBride, 2022-01-18
Tags geometry tick
Categories generativepy generative art

The TickMarker
class is a special Shape that adds a small cross line marker to a line, of the type often used in geometric diagrams to show that two lines are the same length. They look like this:
You can add 1, 2 or 3 ticks.
The TickMarker
only draws the tick, it doesn't draw the line itself. This would normally be draw using a Line object, Polygon object, or similar.
TickMarker class
TickMarker
is derived from the Shape
class. It adds several methods:
of_start_end
with_length
with_count
with_gap
of_start_end
Creates a marker based on a start and end points.
of_start_end(a, b)
Parameter | Type | Description |
---|---|---|
a | (number, number) | Tuple (x, y) for start of line |
b | (number, number) | Tuple (x, y) for end of line |
This will draw an tick marker for the line formed by ab. The tick will be halfway between points a
and b
.
with_length
Sets the length of the tick.
with_length(length)
Parameter | Type | Description |
---|---|---|
length | number | Length of tick in user units. |
The default is 4.
with_count
Sets the number of ticks in the marker.
with_count(count)
Parameter | Type | Description |
---|---|---|
count | int | Number of ticks |
This can be used to draw a single, double, or triple tick. Permitted values are 1, 2, or 3. Default is 1.
with_gap
Sets the gap between the ticks if count > 1
.
with_gap(gap)
Parameter | Type | Description |
---|---|---|
gap | number | Gap between ticks in user units. |
Sets the spacing of the ticks. This is only relevant if there is more than one tick (ie if count > 1
), otherwise it is ignored. The default is 1.
tick function
This older tick
function is deprecated as of GenerativePy 3.1.
tick(ctx, a, b, count=1, length=4, gap=1)
Parameter | Type | Description |
---|---|---|
ctx | Context | The Pycairo Context to draw to |
a | (number, number) | Tuple (x, y) for point a |
b | (number, number) | Tuple (x, y) for point b |
count | int | Number of ticks on the line, 1, 2 or 3. |
length | number | length of the tick in user units. |
gap | number | Gap between ticks in user units. |
Draws an tick across the line ab. The tick is half way between points a
and b
.
Example
See the example in the angle_marker article.