Freehand Context¶
keyed_extras.freehand
¶
A Cairo context for emulating hand drawn shapes.
This code was adapted/extended from the following sources: - Gaphor/Gaphas, most of the implementation - Apache License 2.0 - https://github.com/gaphor/gaphas/blob/main/LICENSES/Apache-2.0.txt - https://github.com/gaphor/gaphas/blob/main/gaphas/painter/freehand.py - Steve Hanov, the original author - Steve Hanov 2008, Released to the public domain. - http://stevehanov.ca/blog/index.php?id=33 and - http://stevehanov.ca/blog/index.php?id=93
FreeHandContext
¶
Bases: base
A Cairo context that looks hand drawn.
This object proxies an underlying Cairo context for methods not implemented directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cr
|
Context
|
The cairo context to proxy. |
required |
sloppiness
|
float
|
In range 0.0 .. 2.0 |
0.5
|
line_to
¶
rel_line_to
¶
curve_to
¶
Draw a bezier curve using the provided control points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
float
|
The x coordinate of the first control point |
required |
y1
|
float
|
The y coordinate of the first control point |
required |
x2
|
float
|
The x coordinate of the second control point |
required |
y2
|
float
|
The y coordinate of the second control point |
required |
x3
|
float
|
the x coordinate of the end of the curve |
required |
y3
|
float
|
the y coordinate of the end of the curve |
required |
Returns:
Type | Description |
---|---|
None
|
None |
rel_curve_to
¶
Relative version of curve_to.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dx1
|
float
|
The x offset of the first control point |
required |
dy1
|
float
|
The y offset of the first control point |
required |
dx2
|
float
|
The x offset of the second control point |
required |
dy2
|
float
|
The y offset of the second control point |
required |
dx3
|
float
|
the x offset of the end of the curve |
required |
dy3
|
float
|
the y offset of the end of the curve |
required |
Returns:
Type | Description |
---|---|
None
|
None |
rectangle
¶
Draw a rectangle.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
float
|
The x coordinate of the top left of the rectangle |
required |
y
|
float
|
The y coordinate of the top left of the rectangle |
required |
width
|
float
|
The width of the rectangle |
required |
height
|
float
|
The height of the rectangle |
required |
Returns:
Type | Description |
---|---|
None
|
None |
arc
¶
Draw an arc about a center with the provided radius from angle1 to angle2.
This splits the arc into multiple segments, and then draws curves between them.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xc
|
float
|
x position of the center of the arc |
required |
yc
|
float
|
y position of the center of the arc |
required |
radius
|
float
|
the radius of the arc |
required |
angle1
|
float
|
the start angle, in radians |
required |
angle2
|
float
|
the end angle, in radians |
required |
Returns:
Type | Description |
---|---|
None
|
None |