Class Defaults
A class to hold default values for various element properties. This class provides a centralized way to manage default settings for elements/ The initial values are:
size(130, 80)
opacity(100)
rotate(0)
sloppiness('artist')
roundness('round')
stroke('solid')
thickness(1)
color('#000000')
background('transparent')
fill('hachure')
fontsize(16)
font('Hand drawn')
align('center')
baseline('middle')
autoresize(True)
spacing(1.25)
arrowheads(None, 'arrow')
Methods
init
Initialize self. See help(type(self)) for accurate signature.align
Set the horizontal text alignment (left, center, right).Arguments
| Name | Type | Description |
|---|---|---|
align |
str |
The horizontal alignment to set. |
Returns
Type: Self
The current instance of the Text class.
Raises
ValueError: If an invalid alignment is provided.
arrowheads
Set the arrowhead styles for the start and end of the arrow. Valid arrowheads values are None, 'arrow', 'bar', 'dot' and 'triangle'.Arguments
| Name | Type | Description |
|---|---|---|
start |
str, optional |
The style of the start arrowhead. |
end |
str, optional |
The style of the end arrowhead. |
Returns
Type: Self
The current instance of the Arrow class.
Raises
ValueError: If an invalid arrowhead style is provided.
autoresize
Enable or disable automatic text box resizing.Arguments
| Name | Type | Description |
|---|---|---|
enabled |
bool |
Whether to enable automatic resizing. |
Returns
Type: Self
The current instance of the Text class.
background
Sets the background color of the element.Arguments
| Name | Type | Description |
|---|---|---|
color |
str or Color |
The background color, specified as a hex string (#RRGGBB), a color name, or a Color object. |
Returns
Type: Self
The instance defaults with updated background color.
baseline
Set the vertical text alignment (top, middle, bottom).Arguments
| Name | Type | Description |
|---|---|---|
align |
str |
The vertical alignment to set. |
Returns
Type: Self
The current instance of the Text class.
Raises
ValueError: If an invalid vertical alignment is provided.
color
Set the stroke (outline) color as #RRGGBB, color name or Color object.Arguments
| Name | Type | Description |
|---|---|---|
color |
str or Color |
The color to set, specified as a hex string $RRGGBB, color name, or Color object. |
Returns
Type: Self
The current instance of the AbstractStrokedElement class.
fill
Sets the fill style of the element.Arguments
| Name | Type | Description |
|---|---|---|
style |
str |
The fill style to be applied. Must be one of 'hachure', 'cross-hatch', or 'solid'. |
Returns
Type: Self
The instance defaults with updated fill style.
font
Sets the font family of the text element.Arguments
| Name | Type | Description |
|---|---|---|
family |
str |
The font family to set, specified as a string ('Excalifont', 'Comic Shaans', 'Lilita One', 'Nunito', 'Hand-drawn', 'Normal', 'Code'). |
Returns
Type: Self
The instance defaults with updated font family.
fontsize
Sets the font size of the text element.Arguments
| Name | Type | Description |
|---|---|---|
size |
int or str |
The font size to set, specified as an integer (e.g., 12, 14, 16) or a string ('small', 'medium', 'large'). |
Returns
Type: Self
The instance defaults with updated font size.
opacity
Sets the opacity of the element.Arguments
| Name | Type | Description |
|---|---|---|
opacity |
int |
The opacity of the element (0-100). |
Returns
Type: Self
The instance defaults with updated opacity.
Raises
ValueError: If the opacity value is not within the range 0-100.
rotate
Sets the rotation angle of the element.Arguments
| Name | Type | Description |
|---|---|---|
angle |
float |
The rotation angle in radians. |
Returns
Type: Self
The instance defaults with updated angle.
roundness
Sets the roundness style of the element.Arguments
| Name | Type | Description |
|---|---|---|
roundness |
str |
The roundness style to set. Acceptable values are: - "sharp": Sets the shape to have sharp corners. - "round": Sets the shape to have rounded corners. Returns: Self: The instance defaults with updated roundness style. |
size
Sets the size of the element.Arguments
| Name | Type | Description |
|---|---|---|
width |
float |
The width of the element. |
height |
float |
The height of the element. |
Returns
Type: Self
The instance defaults with updated size.
sloppiness
Sets the sloppiness of the element.Arguments
| Name | Type | Description |
|---|---|---|
sloppiness |
int or str |
The sloppiness value to set, specified as an integer (0, 1, 2) or a string ('architect', 'artist', 'cartoonist'). |
Returns
Type: Self
The instance defaults with updated sloppiness.
spacing
Set the line height manually.Arguments
| Name | Type | Description |
|---|---|---|
height |
float |
The line height to set. |
Returns
Type: Self
The current instance of the Text class.
stroke
Sets the stroke style of the element.Arguments
| Name | Type | Description |
|---|---|---|
stroke |
str |
The stroke style to set, specified as a string ('solid', 'dashed', 'dotted'). |
Returns
Type: Self
The instance defaults with updated stroke style.
thickness
Sets the stroke thickness of the element.Arguments
| Name | Type | Description |
|---|---|---|
thickness |
int or str |
The thickness to set, specified as an integer (1, 2, 3) or a string ('thin', 'bold', 'extra-bold'). |
Returns
Type: Self
The instance defaults with updated stroke thickness.