Stroke#

Added in version 4.14.

class Stroke(**kwargs)#

Collects the parameters that are needed when stroking a path.

Constructors#

class Stroke
classmethod new(line_width: float) Stroke#

Creates a new GskStroke with the given line_width.

Added in version 4.14.

Parameters:

line_width – line width of the stroke. Must be > 0

Methods#

class Stroke
classmethod equal(stroke1: Any = None, stroke2: Any = None) bool#

Checks if two strokes are identical.

Added in version 4.14.

Parameters:
  • stroke1 – the first stroke

  • stroke2 – the second stroke

free() None#

Frees a GskStroke.

Added in version 4.14.

get_dash() list[float] | None#

Gets the dash array in use.

Added in version 4.14.

get_dash_offset() float#

Gets the dash offset.

Added in version 4.14.

get_line_cap() LineCap#

Gets the line cap used.

See LineCap for details.

Added in version 4.14.

get_line_join() LineJoin#

Gets the line join used.

See LineJoin for details.

Added in version 4.14.

get_line_width() float#

Gets the line width used.

Added in version 4.14.

get_miter_limit() float#

Gets the miter limit.

Added in version 4.14.

set_dash(dash: list[float] | None = None) None#

Sets the dash pattern to use.

A dash pattern is specified by an array of alternating non-negative values. Each value provides the length of alternate “on” and “off” portions of the stroke.

Each “on” segment will have caps applied as if the segment were a separate contour. In particular, it is valid to use an “on” length of 0 with round or square to draw dots or squares along a path.

If n_dash is 0, if all elements in dash are 0, or if there are negative values in dash, then dashing is disabled.

If n_dash is 1, an alternating “on” and “off” pattern with the single dash length provided is assumed.

If n_dash is uneven, the dash array will be used with the first element in dash defining an “on” or “off” in alternating passes through the array.

You can specify a starting offset into the dash with set_dash_offset.

Added in version 4.14.

Parameters:

dash – the array of dashes

set_dash_offset(offset: float) None#

Sets the offset into the dash pattern where dashing should begin.

This is an offset into the length of the path, not an index into the array values of the dash array.

See set_dash for more details on dashing.

Added in version 4.14.

Parameters:

offset – offset into the dash pattern

set_line_cap(line_cap: LineCap) None#

Sets the line cap to be used when stroking.

See LineCap for details.

Added in version 4.14.

Parameters:

line_cap – the line cap

set_line_join(line_join: LineJoin) None#

Sets the line join to be used when stroking.

See LineJoin for details.

Added in version 4.14.

Parameters:

line_join – the line join to use

set_line_width(line_width: float) None#

Sets the line width to be used when stroking.

The line width must be >= 0.

Added in version 4.14.

Parameters:

line_width – width of the line in pixels

set_miter_limit(limit: float) None#

Sets the miter limit to be used when stroking.

The miter limit is the distance from the corner where sharp turns of joins get cut off.

The limit is specfied in units of line width and must be non-negative.

For joins of type miter that exceed the miter limit, the join gets rendered as if it was of type bevel.

Added in version 4.14.

Parameters:

limit – the miter limit

to_cairo(cr: Context) None#

A helper function that sets the stroke parameters of a cairo context from a GskStroke.

Added in version 4.14.

Parameters:

cr – the cairo context to configure