Skip to main content

Paint

A description of the style to use when drawing a shape on the canvas.

Properties

Methods

  • copy - Returns a copy of this object with the specified properties overridden.

Properties

anti_aliasclass-attributeinstance-attribute

anti_alias: bool = True

Whether to apply anti-aliasing to lines and images drawn on the canvas.

blend_modeclass-attributeinstance-attribute

blend_mode: BlendMode = BlendMode.SRC_OVER

A blend mode to apply when a shape is drawn or a layer is composited.

blur_imageclass-attributeinstance-attribute

blur_image: BlurValue | None = None

Blur image when drawing it on a canvas.

colorclass-attributeinstance-attribute

The color to use when stroking or filling a shape.

gradientclass-attributeinstance-attribute

gradient: PaintGradient | None = None

Configures gradient paint.

stroke_capclass-attributeinstance-attribute

stroke_cap: StrokeCap = StrokeCap.BUTT

The kind of finish to place on the ends of stroked lines.

This applies when style is PaintingStyle.STROKE.

stroke_dash_patternclass-attributeinstance-attribute

stroke_dash_pattern: list[Number] | None = None

Dash pattern used when painting stroked outlines.

Values alternate between painted dash lengths and unpainted gap lengths. For example, [5, 10] paints a dash 5 logical pixels long, then leaves a gap 10 logical pixels long, repeating the pattern along the stroked path.

Note

This applies only when style is PaintingStyle.STROKE.

stroke_joinclass-attributeinstance-attribute

stroke_join: StrokeJoin = StrokeJoin.MITER

The kind of finish to place on joins between stroked segments.

This applies when style is PaintingStyle.STROKE.

See also:

stroke_miter_limit

stroke_miter_limitclass-attributeinstance-attribute

stroke_miter_limit: Number = 4.0

The limit for drawing miter joins when stroke_join is StrokeJoin.MITER and style is PaintingStyle.STROKE.

If this limit is exceeded, a bevel join is used instead.

stroke_widthclass-attributeinstance-attribute

stroke_width: Number = 0.0

How wide stroked edges should be, in logical pixels.

This applies when style is PaintingStyle.STROKE. A width of 0.0 corresponds to a hairline.

styleclass-attributeinstance-attribute

Whether to paint filled interiors or only stroked outlines.

Methods

copy

copy(
    color: ColorValue | None = None,
    blend_mode: BlendMode | None = None,
    blur_image: BlurValue | None = None,
    anti_alias: bool | None = None,
    gradient: PaintGradient | None = None,
    stroke_cap: StrokeCap | None = None,
    stroke_join: StrokeJoin | None = None,
    stroke_miter_limit: Number | None = None,
    stroke_width: Number | None = None,
    stroke_dash_pattern: list[Number] | None = None,
    style: PaintingStyle | None = None,
) -> Paint

Returns a copy of this object with the specified properties overridden.