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 | None = None

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

Defaults to True.

blend_modeclass-attributeinstance-attribute

blend_mode: BlendMode | None = None

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

Defaults to BlendMode.SRC_OVER.

blur_imageclass-attributeinstance-attribute

blur_image: BlurValue | None = None

Blur image when drawing it on a canvas.

colorclass-attributeinstance-attribute

color: ColorValue | None = None

The color to use when stroking or filling a shape.

Defaults to opaque black.

gradientclass-attributeinstance-attribute

gradient: PaintGradient | None = None

Configures gradient paint.

stroke_capclass-attributeinstance-attribute

stroke_cap: StrokeCap | None = None

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

This applies when style is PaintingStyle.STROKE. If not set, the effective default is StrokeCap.BUTT.

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 | None = None

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

This applies when style is PaintingStyle.STROKE. If not set, the effective default is StrokeJoin.MITER.

See also:

stroke_miter_limit

stroke_miter_limitclass-attributeinstance-attribute

stroke_miter_limit: Number | None = None

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. If not set, the effective default is 4.0.

stroke_widthclass-attributeinstance-attribute

stroke_width: Number | None = None

How wide stroked edges should be, in logical pixels.

This applies when style is PaintingStyle.STROKE. If not set, the effective default is 0.0, which corresponds to a hairline width.

styleclass-attributeinstance-attribute

style: PaintingStyle | None = None

Whether to paint filled interiors or only stroked outlines.

If not set, the effective default is PaintingStyle.FILL.

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.