Skip to content

DashedStrokePattern

Inherits: StrokePattern

A stroke pattern of alternating dashes and gaps, defined by segments.

Properties

Properties#

pattern_fit class-attribute instance-attribute #

pattern_fit: PatternFit = SCALE_UP

Determines how this stroke pattern should be fit to a line when their lengths are not equal or multiples.

segments instance-attribute #

segments: list[Number]

A list of even length with a minimum of 2, in the form of [a₁, b₁, (a₂, b₂, ...)], where a should be the length of segments in 'units', and b the length of the space after each segment in units. Both values must be strictly positive.

'Units' refers to pixels, unless the pattern has been scaled due to the use of pattern_fit [PatternFit.SCALE_UP][flet.PatternFit.SCALE_UP].

If more than two items are specified, then each segments will alternate/iterate through the values.

For example, [50, 10, 10, 10] will cause:

  • a segment of length 50px
  • followed by a space of 10px
  • followed by a segment of length 10px
  • followed by a space of 10px
  • followed by a segment of length of 50px
  • followed by a space of 10px
  • and so on ...

Raises:

  • ValueError

    If the list does not contain at least two items, or if its length is not even.