Gsk.Stroke

Fields

None

Methods

class

equal (stroke1, stroke2)

class

new (line_width)

copy ()

free ()

get_dash ()

get_dash_offset ()

get_line_cap ()

get_line_join ()

get_line_width ()

get_miter_limit ()

set_dash (dash)

set_dash_offset (offset)

set_line_cap (line_cap)

set_line_join (line_join)

set_line_width (line_width)

set_miter_limit (limit)

to_cairo (cr)

Details

class Gsk.Stroke

Collects the parameters that influence the operation of stroking a path.

New in version 4.14.

classmethod equal(stroke1, stroke2)
Parameters:
Returns:

true if the two strokes are equal, false otherwise

Return type:

bool

Checks if two strokes are identical.

New in version 4.14.

classmethod new(line_width)
Parameters:

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

Returns:

a new GskStroke

Return type:

Gsk.Stroke

Creates a new GskStroke with the given line_width.

New in version 4.14.

copy()
Returns:

a new GskStroke. Use [method`Gsk`.Stroke.free] to free it

Return type:

Gsk.Stroke

Creates a copy of a GskStroke.

New in version 4.14.

free()

Frees a GskStroke.

New in version 4.14.

get_dash()
Returns:

the dash array or NULL if the dash array is empty

Return type:

[float] or None

Gets the dash array in use.

New in version 4.14.

get_dash_offset()
Returns:

the dash offset

Return type:

float

Gets the dash offset.

New in version 4.14.

get_line_cap()
Returns:

the line cap

Return type:

Gsk.LineCap

Gets the line cap used.

See [enum`Gsk`.LineCap] for details.

New in version 4.14.

get_line_join()
Returns:

the line join

Return type:

Gsk.LineJoin

Gets the line join used.

See [enum`Gsk`.LineJoin] for details.

New in version 4.14.

get_line_width()
Returns:

the line width

Return type:

float

Gets the line width used.

New in version 4.14.

get_miter_limit()
Returns:

the miter limit

Return type:

float

Gets the miter limit.

New in version 4.14.

set_dash(dash)
Parameters:

dash ([float] or None) – the array of dashes

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 [enum`Gsk`.LineCap.round] or [enum`Gsk`.LineCap.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 [method`Gsk`.Stroke.set_dash_offset].

New in version 4.14.

set_dash_offset(offset)
Parameters:

offset (float) – offset into the dash pattern

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 [method`Gsk`.Stroke.set_dash] for more details on dashing.

New in version 4.14.

set_line_cap(line_cap)
Parameters:

line_cap (Gsk.LineCap) – the line cap

Sets the line cap to be used when stroking.

See [enum`Gsk`.LineCap] for details.

New in version 4.14.

set_line_join(line_join)
Parameters:

line_join (Gsk.LineJoin) – the line join to use

Sets the line join to be used when stroking.

See [enum`Gsk`.LineJoin] for details.

New in version 4.14.

set_line_width(line_width)
Parameters:

line_width (float) – width of the line in pixels

Sets the line width to be used when stroking.

The line width must be > 0.

New in version 4.14.

set_miter_limit(limit)
Parameters:

limit (float) – the miter limit

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 [enum`Gsk`.LineJoin.miter] that exceed the miter limit, the join gets rendered as if it was of type [enum`Gsk`.LineJoin.bevel].

New in version 4.14.

to_cairo(cr)
Parameters:

cr (cairo.Context) – the cairo context to configure

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

New in version 4.14.