Reference¶
-
class
TurksHead
(bights, leads, inner, outer, line, colorer=None)¶ Turk’s head knot objects.
Parameters: - bights – the number of times the string touches the outised of the knot.
- leads – the number of times the string turns around the center.
- inner – the radius of the empty area inside the knot.
- outer – the radius of the knot.
- line – the width of the string.
- colorer – a
Colorer
instance. IfNone
or not provided, aDefaultColorer
will be used.
-
p
¶ The number of bights.
-
q
¶ The number of leads.
-
inner_radius
¶ The radius of the empty area inside the knot.
-
outer_radius
¶ The radius of the knot.
-
line_width
¶ The width of the string.
-
draw
(ctx)¶ Draw the knot on a
cairo.Context
. See documentation of PyCairo.
-
class
Colorer
¶ Objects passed as the
colorer
argument ofTurksHead
must implement this interface. More precisely, they must implement one of the following methods:-
compute_color_hsv(knot, k, theta, altitude):
Return a tuple
(h, s, v)
of the color to be applied to thek
-th string of theknot
, at angletheta
, at the givenaltitude
.h
must be between 0 and 360s
andv
must be between 0 and 1.Parameters: - knot – the
TurksHead
instance. - k – the index of the current string. Between 0 and
knot.d
. - theta – the angle on the current string. Between 0 and
2 * knot.q_prime * math.pi
. - altitude – the altitude of the string at this point. Between -1 and 1.
- knot – the
-
compute_color_rgb(knot, k, theta, altitude):
Return a tuple
(r, g, b)
of the color to be applied to thek
-th string of theknot
, at angletheta
, at the givenaltitude
.r
,g
andb
must be between 0 and 1.Parameters: - knot – the
TurksHead
instance. - k – the index of the current string. Between 0 and
knot.d
. - theta – the angle on the current string. Between 0 and
2 * knot.q_prime * math.pi
. - altitude – the altitude of the string at this point. Between -1 and 1.
- knot – the
-