Defining Styles

viren2d.ArrowStyle

How an arrow should be drawn.

viren2d.BoundingBox2DStyle

How a 2D bounding box should be drawn."

viren2d.LineStyle

How a line/contour should be drawn.

viren2d.MarkerStyle

How a marker/keypoint should be drawn.

viren2d.TextStyle

How text should be rendered.

Arrow Style

class viren2d.ArrowStyle

Bases: LineStyle

How an arrow should be drawn.

Example

>>> style = viren2d.ArrowStyle(
>>>     width=5, color='black',
>>>     tip_length=0.3, tip_angle=20,
>>>     tip_closed=True, double_headed=False,
>>>     dash_pattern=[], dash_offset=0.0,
>>>     cap='round', join='miter')

Style cheat sheet for arrows

Methods:

__eq__

Checks for equality.

__getstate__

__init__

Creates a customized arrow style.

__ne__

Checks for inequality.

__setstate__

ArrowStyle instances can be pickled.

as_dict

Returns a dictionary representation.

copy

Returns a deep copy.

detailed_str

Returns a verbose string representation to facilitate debugging.

is_dashed

Checks if this style contains a dash stroke pattern.

is_valid

Checks if the style would lead to a drawable arrow.

tip_length_for_shaft

Returns the length of the arrow head for the given shaft length.

Attributes:

cap

How to render the endpoints" of the line (or dash strokes).

color

Color of the line.

dash_offset

Offset into the pattern at which the dash stroke begins.

dash_pattern

Dash pattern defined as list of on/off strokes.

double_headed

If True, arrow heads will be drawn on both ends.

join

How to render the junctions of the line segments.

tip_angle

Interior angle (in degrees) between shaft and tip.

tip_closed

If True, the arrow head will be filled.

tip_length

Length of the arrow tip.

width

Width/thickness in pixels.

__eq__(self: viren2d.ArrowStyle, arg0: viren2d.ArrowStyle) bool

Checks for equality.

__getstate__(self: viren2d.ArrowStyle) tuple
__init__(self: viren2d.ArrowStyle, width: float = 2.0, color: viren2d.Color = viren2d.Color(red=0, green=0.5, blue=1, alpha=1), tip_length: float = 0.2, tip_angle: float = 20.0, tip_closed: bool = False, double_headed: bool = False, dash_pattern: List[float] = [], dash_offset: float = 0.0, cap: viren2d.LineCap = <LineCap.Round>, join: viren2d.LineJoin = <LineJoin.Miter>) None

Creates a customized arrow style.

Parameters:
  • width – Width in pixels as float.

  • color – Arrow color as Color.

  • tip_length – Length of the arrow tip as float. If it is between [0, 1], it is interpreted as percentage of the shaft length. Otherwise, it represents the absolute length in pixels.

  • tip_angle – Interior angle between shaft and tip, specified in degrees as float.

  • tip_closed – Set True to fill the tip (type bool).

  • double_headed – Set True to draw arrow tips on both ends of the shaft (type bool).

  • dash_pattern – Dash pattern defined as list of float, specifying the on/off strokes. Refer to the documentation of the class member dash_pattern for details.

  • dash_offset – Optional offset (length as float) into the pattern, at which the dash stroke begins. Refer to the class member dash_offset for details.

  • cap – A LineCap enum, specifying how to render the line endpoints. This parameter can also be set using the corresponding string representation, e.g. 'round'.

  • join – A LineJoin enum, specifying how to render the junctions of multi-segment lines. This parameter can also be set using the corresponding string representation, e.g. 'miter'.

__ne__(self: viren2d.ArrowStyle, arg0: viren2d.ArrowStyle) bool

Checks for inequality.

__setstate__(self: viren2d.ArrowStyle, arg0: tuple) None

ArrowStyle instances can be pickled.

as_dict(self: viren2d.ArrowStyle) dict

Returns a dictionary representation.

property cap

How to render the endpoints” of the line (or dash strokes).

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.cap = viren2d.LineCap.Round
>>> style.cap = 'round'
Type:

LineCap

property color

Color of the line.

Example:

>>> style.color = viren2d.Color(1, 0, 1)
>>> style.color = viren2d.RGBa(255, 0, 255)
>>> style.color = 'magenta'
Type:

Color

copy(self: viren2d.ArrowStyle) viren2d.ArrowStyle

Returns a deep copy.

Corresponding C++ API: Copy constructor of viren2d::ArrowStyle.

property dash_offset

Offset into the pattern at which the dash stroke begins.

If the strokes of a dash_pattern do not align nicely, adjust this offset (measured in pixels).

Type:

float

property dash_pattern

Dash pattern defined as list of on/off strokes.

A dash pattern is a list of positive values. Each value defines the length (in pixels) of alternating on and off segments of the line. For solid lines, this list must be empty.

>>> style.dash_pattern = [20, 30, 40, 10] # Would result in:
'__   ____ __   ____ __   ____ __   ____ __   ____ __   ____ ...'
Type:

list[float]

detailed_str(self: viren2d.LineStyle) str

Returns a verbose string representation to facilitate debugging.

property double_headed

If True, arrow heads will be drawn on both ends.

Type:

bool

is_dashed(self: viren2d.LineStyle) bool

Checks if this style contains a dash stroke pattern.

is_valid(self: viren2d.ArrowStyle) bool

Checks if the style would lead to a drawable arrow.

property join

How to render the junctions of the line segments.

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.join = viren2d.LineJoin.Miter
>>> style.cap = 'miter'
Type:

LineJoin

property tip_angle

Interior angle (in degrees) between shaft and tip.

Type:

float

property tip_closed

If True, the arrow head will be filled.

Type:

bool

property tip_length

Length of the arrow tip.

If the value is between [0, 1], it is interpreted as percentage of the arrow’s shaft length. Otherwise, it represents the absolute length in pixels.

Type:

float

tip_length_for_shaft(self: viren2d.ArrowStyle, shaft_length: float) float

Returns the length of the arrow head for the given shaft length.

property width

Width/thickness in pixels.

Due to the discrete pixel grid and the internal drawing conventions, odd line widths usually avoid anti-aliasing effects.

Type:

float

Bounding Box Style

Warning

TODO documentation + cheat sheet

class viren2d.BoundingBox2DStyle

How a 2D bounding box should be drawn.”

Example

>>> line_style = viren2d.LineStyle(
>>>   width=7, color='navy-blue',
>>>   dash_pattern=[], dash_offset=0.0,
>>>   cap='round', join='miter')
>>> text_style = viren2d.TextStyle(
>>>   family='monospace', size=18,
>>>   color='navy-blue', bold=True,
>>>   italic=False, line_spacing=1.1,
>>>   halign='left', valign='top')
>>> box_style = viren2d.BoundingBox2DStyle(
>>>   line_style=line_style, text_style=text_style,
>>>   box_fill_color='same!20', text_fill_color='white!60',
>>>   clip_label=True)

Methods:

__eq__

Checks for equality.

__getstate__

__init__

Creates a customized bounding box style.

__ne__

Checks for inequality.

__setstate__

BoundingBox2DStyle instances can be pickled.

copy

Returns a deep copy.

is_valid

Returns True if the style allows rendering a 2D bounding box.

Attributes:

box_fill_color

Fill color of the bounding box.

clip_label

Set to True to clip the label at the bounding box edges.

label_padding

Padding between bounding box edges and label text.

line_style

How to draw the bounding box contour.

text_fill_color

Fill color of the text box, i.e. the label background.

text_style

How to render the label.

__eq__(self: viren2d.BoundingBox2DStyle, arg0: viren2d.BoundingBox2DStyle) bool

Checks for equality.

__getstate__(self: viren2d.BoundingBox2DStyle) tuple
__init__(self: viren2d.BoundingBox2DStyle, line_style: viren2d.LineStyle = <LineStyle(2.0px, #007fff, solid)>, text_style: viren2d.TextStyle = <TextStyle("monospace", 16px, ls=1.2, left, top, #000000)>, box_fill_color: viren2d.Color = viren2d.Color.Same.with_alpha(0.1), text_fill_color: viren2d.Color = viren2d.Color.Same.with_alpha(0.5), label_padding: viren2d.Vec2d = viren2d.Vec2d(5, 5), clip_label: bool = True) None

Creates a customized bounding box style.

Parameters:
  • line_style – A LineStyle specifying how to render the box outline.

  • text_style – A TextStyle specifying how to render the label text.

  • box_fill_color – Optional Color to fill the box.

  • text_fill_color – Optional Color to fill the background of the label.

  • label_padding – Padding between the nearest bounding box edges and the label as Vec2d.

  • clip_label – If True, the label will be clipped if it exceeds the bounding box.

__ne__(self: viren2d.BoundingBox2DStyle, arg0: viren2d.BoundingBox2DStyle) bool

Checks for inequality.

__setstate__(self: viren2d.BoundingBox2DStyle, arg0: tuple) None

BoundingBox2DStyle instances can be pickled.

property box_fill_color

Fill color of the bounding box.

Type:

Color

property clip_label

Set to True to clip the label at the bounding box edges.

Type:

bool

copy(self: viren2d.BoundingBox2DStyle) viren2d.BoundingBox2DStyle

Returns a deep copy.

Corresponding C++ API: Copy constructor of viren2d::BoundingBox2DStyle.

is_valid(self: viren2d.BoundingBox2DStyle) bool

Returns True if the style allows rendering a 2D bounding box.

property label_padding

Padding between bounding box edges and label text.

Type:

Vec2d

property line_style

How to draw the bounding box contour.

Type:

LineStyle

property text_fill_color

Fill color of the text box, i.e. the label background.

Type:

Color

property text_style

How to render the label.

Type:

TextStyle

Line Style

class viren2d.LineStyle

How a line/contour should be drawn.

Note that several draw_xxx methods of the Painter also accept the special member LineStyle.Invalid, which indicates that a shape should only be filled, but it’s contour should not be drawn. Alternatively, None will also be implicitly converted to LineStyle.Invalid wherever a LineStyle object is expected.

Set the line width to an odd value to avoid anti-aliasing effects.

Example

>>> style = viren2d.LineStyle(
>>>     width=7, color='crimson',
>>>     dash_pattern=[20, 10], dash_offset=0.0,
>>>     cap='round', join='miter')

Note that depending on the selected cap (or join), the corresponding line (or joints) may start/end not exactly where you specified. If you want pixel-accurate start/end in combination with a particular cap/join, use cap_offset() (or join_offset()). For example:

>>> # Choose a cap which results in an offset:
>>> line_style = viren2d.LineStyle(cap='round')
>>>
>>> # Endpoints of our line:
>>> start = viren2d.Vec2d(10, 10)
>>> end = viren2d.Vec2d(100, 100)
>>>
>>> # Now, to draw a line exactly from `start` to `end`,
>>> # we adjust the endpoints:
>>> unit_dir = start.direction_vector(end).unit_vector()
>>> start += line_style.cap_offset() * unit_dir
>>> end -= line_style.cap_offset() * unit_dir

Style cheat sheet for lines

Methods:

__eq__

Checks for equality.

__getstate__

__init__

Overloaded function.

__ne__

Checks for inequality.

__setstate__

LineStyle instances can be pickled.

as_dict

Returns a dictionary representation.

cap_offset

Computes how much the line cap will extend the line's start/end.

copy

Returns a deep copy.

detailed_str

Returns a verbose string representation to facilitate debugging.

is_dashed

Checks if this style contains a dash stroke pattern.

is_valid

Checks if the style would lead to a drawable line.

join_offset

Computes how much a line join will extend the joint.

Attributes:

cap

How to render the endpoints" of the line (or dash strokes).

color

Color of the line.

dash_offset

Offset into the pattern at which the dash stroke begins.

dash_pattern

Dash pattern defined as list of on/off strokes.

join

How to render the junctions of the line segments.

width

Width/thickness in pixels.

__eq__(self: viren2d.LineStyle, arg0: viren2d.LineStyle) bool

Checks for equality.

__getstate__(self: viren2d.LineStyle) tuple
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: viren2d.LineStyle, width: float = 2.0, color: viren2d.Color = viren2d.Color(red=0, green=0.5, blue=1, alpha=1), dash_pattern: List[float] = [], dash_offset: float = 0.0, cap: viren2d.LineCap = <LineCap.Butt>, join: viren2d.LineJoin = <LineJoin.Miter>) -> None

Creates a customized line style.

Parameters:
  • width – Width in pixels as float.

  • color – Line color as Color.

  • dash_pattern – Dash pattern defined as list[float] of on/off strokes, refer to the class member dash_pattern for details.

  • dash_offset – Optional offset into the pattern, at which the dash stroke begins (as float). Refer to the class member dash_offset for details.

  • cap – A LineCap enum, specifying how to render the line endpoints. This parameter can also be set using the corresponding string representation, e.g. 'round'.

  • join – A LineJoin enum, specifying how to render the junctions of multi-segment lines. This parameter can also be set using the corresponding string representation, e.g. 'miter'.

  1. __init__(self: viren2d.LineStyle, none: None) -> None

    Overloaded constructor to implicitly convert None to viren2d.LineStyle.Invalid.

    Several drawing methods of the Painter support skipping the contour and only filling a shape. For example:

    >>> painter.draw_rect(rect, line_style=None, fill_color='blue!40')
    
__ne__(self: viren2d.LineStyle, arg0: viren2d.LineStyle) bool

Checks for inequality.

__setstate__(self: viren2d.LineStyle, arg0: tuple) None

LineStyle instances can be pickled.

as_dict(self: viren2d.LineStyle) dict

Returns a dictionary representation.

Convenience method to initialize an ArrowStyle from a LineStyle via dictionary unpacking (aka splat operator):

>>> arrow_style = viren2d.ArrowStyle(
>>>     **line_style.as_dict(),
>>>     tip_length=0.3)
property cap

How to render the endpoints” of the line (or dash strokes).

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.cap = viren2d.LineCap.Round
>>> style.cap = 'round'
Type:

LineCap

cap_offset(self: viren2d.LineStyle) float

Computes how much the line cap will extend the line’s start/end.

property color

Color of the line.

Example:

>>> style.color = viren2d.Color(1, 0, 1)
>>> style.color = viren2d.RGBa(255, 0, 255)
>>> style.color = 'magenta'
Type:

Color

copy(self: viren2d.LineStyle) viren2d.LineStyle

Returns a deep copy.

Corresponding C++ API: Copy constructor of viren2d::LineStyle.

property dash_offset

Offset into the pattern at which the dash stroke begins.

If the strokes of a dash_pattern do not align nicely, adjust this offset (measured in pixels).

Type:

float

property dash_pattern

Dash pattern defined as list of on/off strokes.

A dash pattern is a list of positive values. Each value defines the length (in pixels) of alternating on and off segments of the line. For solid lines, this list must be empty.

>>> style.dash_pattern = [20, 30, 40, 10] # Would result in:
'__   ____ __   ____ __   ____ __   ____ __   ____ __   ____ ...'
Type:

list[float]

detailed_str(self: viren2d.LineStyle) str

Returns a verbose string representation to facilitate debugging.

is_dashed(self: viren2d.LineStyle) bool

Checks if this style contains a dash stroke pattern.

is_valid(self: viren2d.LineStyle) bool

Checks if the style would lead to a drawable line.

property join

How to render the junctions of the line segments.

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.join = viren2d.LineJoin.Miter
>>> style.cap = 'miter'
Type:

LineJoin

join_offset(self: viren2d.LineStyle, interior_angle: float, miter_limit: float = 10.0) float

Computes how much a line join will extend the joint.

The interior_angle is the angle between two line segments in degrees. This method needs to know the miter_limit because Cairo switches from MITER to BEVEL if the miter_limit is exceeded. Refer to the Cairo documentation for details.

property width

Width/thickness in pixels.

Due to the discrete pixel grid and the internal drawing conventions, odd line widths usually avoid anti-aliasing effects.

Type:

float

Marker Style

Available Marker Shapes

class viren2d.MarkerStyle

How a marker/keypoint should be drawn.

Example

>>> style = viren2d.MarkerStyle(
>>>     marker='*', size=10, color='navy-blue!80',
>>>     thickness=1, filled=True,
>>>     cap='round', join='miter')

Methods:

__eq__

Checks for equality.

__getstate__

__init__

Creates a customized marker style.

__ne__

Checks for inequality.

__setstate__

MarkerStyle instances can be pickled.

cap_offset

Computes how much the line cap will extend the start/end of the lines.

copy

Returns a deep copy.

is_filled

Returns True if this marker would be filled.

is_valid

Checks if this style would lead to a drawable marker.

join_offset

Computes how much a line join will extend the joint.

Attributes:

bg_border

Can be used to improve the contrast of the marker.

bg_color

Can be used to improve the contrast, see bg_border.

cap

How to render the endpoints of the marker's contour.

color

Color of the marker's contour or fill (depending on filled).

filled

If True, the marker should be filled with color.

join

How to render the junctions of the marker's contour.

marker

Marker shape.

size

Marker size in pixels.

thickness

Thickness of the marker's contour.

__eq__(self: viren2d.MarkerStyle, arg0: viren2d.MarkerStyle) bool

Checks for equality.

__getstate__(self: viren2d.MarkerStyle) tuple
__init__(self: viren2d.MarkerStyle, marker: viren2d.Marker = viren2d.Marker('o'), size: float = 10.0, thickness: float = 3.0, color: viren2d.Color = viren2d.Color(red=0, green=0.5, blue=1, alpha=1), filled: bool = False, bg_border: float = 0.0, bg_color: viren2d.Color = viren2d.Color.Invalid, cap: viren2d.LineCap = <LineCap.Round>, join: viren2d.LineJoin = <LineJoin.Miter>) None

Creates a customized marker style.

Parameters:
  • marker – Shape as Marker enumeration value or its character representation.

  • size – Marker size in pixels as float.

  • thickness – Width/thickness of the contour in pixels as float.

  • color – The Color used for drawing its contour or filling.

  • filled – If True (and the shape allwos), the marker will be filled.

  • bg_border – Can be used to improve the contrast of the marker. If bg_color is valid, a circle (or square for 's') will be drawn behind the actual marker. Size of this circle will be size + 2 * bg_border.

  • bg_color – The Color to improve the contrast, see bg_thickness.

  • cap – A LineCap enum, specifying how to render the line endpoints. This parameter can also be set via the corresponding string representation, e.g. 'round'.

  • join – A LineJoin enum, specifying how to render the junctions of multi-segment lines. This parameter can also be set via the corresponding string representation, e.g. 'miter'.

__ne__(self: viren2d.MarkerStyle, arg0: viren2d.MarkerStyle) bool

Checks for inequality.

__setstate__(self: viren2d.MarkerStyle, arg0: tuple) None

MarkerStyle instances can be pickled.

property bg_border

Can be used to improve the contrast of the marker. If bg_color is valid, a circle (or square for 's') will be drawn behind the actual marker. Size of this circle will be size + 2 * bg_border.

Type:

float

property bg_color

Can be used to improve the contrast, see bg_border.

Type:

Color

property cap

How to render the endpoints of the marker’s contour.

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.cap = viren2d.LineCap.Round
>>> style.cap = 'round'
Type:

LineCap

cap_offset(self: viren2d.MarkerStyle) float

Computes how much the line cap will extend the start/end of the lines.

property color

Color of the marker’s contour or fill (depending on filled).

Type:

Color

copy(self: viren2d.MarkerStyle) viren2d.MarkerStyle

Returns a deep copy.

Corresponding C++ API: Copy constructor of viren2d::MarkerStyle.

property filled

If True, the marker should be filled with color.

Note that some marker shapes cannot be filled (e.g '+' or 'o'), whereas some shapes must be filled (e.g. '.'). For such shapes, the value of filled will be ignored.

Type:

bool

is_filled(self: viren2d.MarkerStyle) bool

Returns True if this marker would be filled.

Note that this may differ from its filled member: Some marker shapes cannot be filled (e.g '+' or 'o'), whereas some shapes must be filled (e.g. '.').

is_valid(self: viren2d.MarkerStyle) bool

Checks if this style would lead to a drawable marker.

property join

How to render the junctions of the marker’s contour.

In addition to the enumeration values, you can use the corresponding string representation to set this member:

>>> style.join = viren2d.LineJoin.Miter
>>> style.join = 'miter'
Type:

LineJoin

join_offset(self: viren2d.MarkerStyle, interior_angle: float, miter_limit: float = 10.0) float

Computes how much a line join will extend the joint.

The interior_angle is the angle between two line segments in degrees. This method needs to know the miter_limit because Cairo switches from MITER to BEVEL if the miter_limit is exceeded. Refer to the Cairo documentation for details.

property marker

Marker shape.

In addition to the enumeration values, you can use the character codes to set this member:

>>> style.marker = viren2d.Marker.Cross
>>> style.marker = 'x'
Type:

Marker

property size

Marker size in pixels.

Type:

float

property thickness

Thickness of the marker’s contour. May be ignored if the shape is fillable and you set filled, i.e. filling takes precedence over drawing the outline.

Type:

float

Text Style

Cheat Sheet for Anchor:

Text anchors

class viren2d.TextStyle

How text should be rendered.

Corresponding C++ API: viren2d::TextStyle.

Example

>>> text_style = viren2d.TextStyle(
>>>     family='monospace', size=18,
>>>     color='navy-blue', bold=True,
>>>     italic=False, line_spacing=1.1,
>>>     halign='left', valign='top')

Methods:

__eq__

Checks for equality.

__getstate__

__init__

Creates a customized text style.

__ne__

Checks for inequality.

__setstate__

TextStyle instances can be pickled.

copy

Returns a deep copy.

is_valid

Returns True if the style allows rendering text.

Attributes:

bold

If True, the font weight will be bold.

color

Color of the text glyphs.

family

Name of the font family.

halign

Horizontal alignment of multi-line text.

italic

If True, the font slant will be italic.

line_spacing

Scaling factor of the vertical distance between consecutive lines of text.

size

Font size in pixels.

valign

Vertical alignment of multi-line text.

__eq__(self: viren2d.TextStyle, arg0: viren2d.TextStyle) bool

Checks for equality.

__getstate__(self: viren2d.TextStyle) tuple
__init__(self: viren2d.TextStyle, size: int = 16, family: str = 'monospace', color: viren2d.Color = viren2d.Color(red=0, green=0, blue=0, alpha=1), bold: bool = False, italic: bool = False, line_spacing: float = 1.2, halign: viren2d.HorizontalAlignment = viren2d.HorizontalAlignment('left'), valign: object = viren2d.VerticalAlignment('top')) None

Creates a customized text style.

Parameters:
  • size – Font size in pixels as float.

  • family – Name of the font family. Refer to the class member family for details.

  • color – Text color as Color.

  • bold – If True, the font weight will be bold (type bool).

  • italic – If True, the font slant will be italic (type bool).

  • line_spacing – Scaling factor of the vertical distance between consecutive lines of text.

  • halign – Horizontal alignment of multi-line text as HorizontalAlignment enum. This parameter also accepts the corresponding string representation.

  • valign – Vertical alignment of multi-line text as VerticalAlignment enum. This parameter also accepts the corresponding string representation. Only affects alignment of fixed-size text boxes, see draw_text_box().

__ne__(self: viren2d.TextStyle, arg0: viren2d.TextStyle) bool

Checks for inequality.

__setstate__(self: viren2d.TextStyle, arg0: tuple) None

TextStyle instances can be pickled.

property bold

If True, the font weight will be bold.

Corresponding C++ API: viren2d::TextStyle::bold.

Type:

bool

property color

Color of the text glyphs.

Corresponding C++ API: viren2d::TextStyle::color.

Type:

Color

copy(self: viren2d.TextStyle) viren2d.TextStyle

Returns a deep copy.

Corresponding C++ API: Copy constructor of viren2d::TextStyle.

property family

Name of the font family.

Most available fonts on the system should be supported. If you experience issues, try the generic CSS2 family names first, e.g. serif, sans-serif, or monospace. Refer to the Cairo documentation for more details.

Corresponding C++ API: viren2d::TextStyle::family.

Type:

str

property halign

Horizontal alignment of multi-line text.

In addition to the enumeration values, you can use the string representations (left|west, center|middle, right|east) to set this member:

>>> style.halign = viren2d.HorizontalAlignment.Center
>>> style.halign = 'center'

Corresponding C++ API: viren2d::TextStyle::halign.

Type:

HorizontalAlignment

is_valid(self: viren2d.TextStyle) bool

Returns True if the style allows rendering text.

Corresponding C++ API: viren2d::TextStyle::IsValid.

property italic

If True, the font slant will be italic.

Corresponding C++ API: viren2d::TextStyle::italic.

Type:

bool

property line_spacing

Scaling factor of the vertical distance between consecutive lines of text.

Corresponding C++ API: viren2d::TextStyle::line_spacing.

Type:

float

property size

Font size in pixels.

Corresponding C++ API: viren2d::TextStyle::size.

Type:

float

property valign

Vertical alignment of multi-line text. Will only affect the output of fixed-size text boxes, see draw_text_box().

In addition to the enumeration values, you can use the string representations (top|north, center|middle, bottom|south) to set this member:

>>> style.valign = viren2d.VerticalAlignment.Center
>>> style.valign = 'center'

Corresponding C++ API: viren2d::TextStyle::valign.

Type:

VerticalAlignment