S or /

SourceClass Paint

from skia import Paint
class Paint:

Paint controls options applied when drawing.

Constants§

Blend: Final[type]§
ClipOp: Final[type]§
FilterQuality: Final[type]§
Style: Final[type]§
TextAlign: Final[type]§

Properties§

@property def antialias(self, /) -> bool§
@antialias.setter def antialias(self, /, value: bool) -> None§
@property def autohinted(self, /) -> bool§
@autohinted.setter def autohinted(self, /, _value: bool) -> None§
@property def blendmode(self, /) -> BlendMode |None§
@blendmode.setter def blendmode(self, /, mode: BlendMode) -> None§
Source@property def color(self, /) -> Color§

Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.

Returns unpremultiplied ARGB.

Source@color.setter def color(self, /, color: Any) -> None§

Sets alpha and RGB used when stroking and filling. The color is a 32-bit value, unpremultiplied, packing 8-bit components for alpha, red, blue, and green.

  • color unpremultiplied ARGB

Example (C++): https://fiddle.skia.org/c/@Paint_setColor

@property def colorfilter(self, /) -> Any |None§
@colorfilter.setter def colorfilter(self, /, _colorfilter: Any |None) -> None§
@property def dev_kern_text(self, /) -> bool§
@dev_kern_text.setter def dev_kern_text(self, /, _value: bool) -> None§
@property def dither(self, /) -> bool§
Source@dither.setter def dither(self, /, value: bool) -> None§

Requests, but does not require, to distribute color error.

  • dither setting for dithering
@property def embedded_bitmap_text(self, /) -> bool§
@embedded_bitmap_text.setter def embedded_bitmap_text(self, /, value: bool) -> None§
@property def fake_bold_text(self, /) -> bool§
@fake_bold_text.setter def fake_bold_text(self, /, value: bool) -> None§
@property def filter_quality(self, /) -> FilterQuality§
@filter_quality.setter def filter_quality(self, /, _quality: FilterQuality) -> None§
@property def font(self, /) -> Font§
@font.setter def font(self, /, font: Font) -> None§
@property def hinting(self, /) -> FontHinting§
@hinting.setter def hinting(self, /, hinting: FontHinting) -> None§
@property def imagefilter(self, /) -> Any |None§
@imagefilter.setter def imagefilter(self, /, filter: ImageFilter |None) -> None§
@property def lcd_render_text(self, /) -> bool§
@lcd_render_text.setter def lcd_render_text(self, /, _value: bool) -> None§
@property def linear_text(self, /) -> bool§
@linear_text.setter def linear_text(self, /, value: bool) -> None§
@property def maskfilter(self, /) -> Any |None§
@maskfilter.setter def maskfilter(self, /, _maskfilter: Any |None) -> None§
Source@property def path_effect(self, /) -> Any |None§

Returns PathEffect if set, or None. Does not alter PathEffect SkRefCnt.

Returns PathEffect if previously set, None otherwise.

Example (C++): https://fiddle.skia.org/c/@Paint_refPathEffect

Source@path_effect.setter def path_effect(self, /, _effect: Any |None) -> None§

Sets PathEffect to path_effect, decreasing SkRefCnt of the previous PathEffect. Pass None to leave the path geometry unaltered.

Increments path_effect SkRefCnt by one.

  • path_effect replace skia.Path with a modification when drawn

Example (C++): https://fiddle.skia.org/c/@Mask_Filter_Methods Example (C++): https://fiddle.skia.org/c/@Paint_setPathEffect

Source@property def shader(self, /) -> Shader |None§

Returns optional colors used when filling a path, such as a gradient.

Does not alter Shader SkRefCnt.

Returns Shader if previously set, None otherwise.

Example (C++): https://fiddle.skia.org/c/@Paint_refShader

Source@shader.setter def shader(self, /, shader: Shader |None) -> None§

Sets optional colors used when filling a path, such as a gradient.

Sets Shader to shader, decreasing SkRefCnt of the previous Shader. Increments shader SkRefCnt by one.

  • shader how geometry is filled with color; if None, color is used instead

Example (C++): https://fiddle.skia.org/c/@Color_Filter_Methods Example (C++): https://fiddle.skia.org/c/@Paint_setShader

Source@property def stroke_cap(self, /) -> StrokeCap§

Returns the geometry drawn at the beginning and end of strokes.

Source@stroke_cap.setter def stroke_cap(self, /, cap: StrokeCap) -> None§

Sets the geometry drawn at the beginning and end of strokes.

Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeCap_a Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeCap_b

Source@property def stroke_join(self, /) -> StrokeJoin§

Returns the geometry drawn at the corners of strokes.

Source@stroke_join.setter def stroke_join(self, /, join: StrokeJoin) -> None§

Sets the geometry drawn at the corners of strokes.

Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeJoin

Source@property def stroke_miter(self, /) -> float§

Returns the limit at which a sharp corner is drawn beveled.

Returns zero and greater miter limit.

Source@stroke_miter.setter def stroke_miter(self, /, miter: float) -> None§

When stroking a small joinAngle with miter, the miterLength may be very long. When miterLength > maxMiterLength (or joinAngle < minJoinAngle) the join will become bevel. miterLimit = maxMiterLength / strokeWidth or miterLimit = 1 / sin(minJoinAngle / 2).

This call has no effect if the miter_limit passed is less than zero. Values less than one will be treated as bevel.

  • miter_limit zero and greater miter limit

Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeMiter

Source@property def stroke_width(self, /) -> float§

Returns the thickness of the pen used by Paint to outline the shape.

Returns zero for hairline, greater than zero for pen thickness.

Source@stroke_width.setter def stroke_width(self, /, width: float) -> None§

Sets the thickness of the pen used by the paint to outline the shape. A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one pixel wide in device space (their thickness does not change as the canvas is scaled). Negative stroke-widths are invalid; setting a negative width will have no effect.

  • width zero thickness for hairline; greater than zero for pen thickness

Example (C++): https://fiddle.skia.org/c/@Miter_Limit Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeWidth

Source@property def style(self, /) -> PaintStyle§

Returns whether the geometry is filled, stroked, or filled and stroked.

Source@style.setter def style(self, /, style: Any) -> None§

Sets whether the geometry is filled, stroked, or filled and stroked. Has no effect if style is not a legal Style value.

Example (C++): https://fiddle.skia.org/c/@Paint_setStyle Example (C++): https://fiddle.skia.org/c/@Stroke_Width

@property def subpixel_text(self, /) -> bool§
@subpixel_text.setter def subpixel_text(self, /, value: bool) -> None§
@property def text_align(self, /) -> TextAlign§
@text_align.setter def text_align(self, /, align: Any) -> None§
@property def text_scale_x(self, /) -> float§
@text_scale_x.setter def text_scale_x(self, /, scale: float) -> None§
@property def text_skew_x(self, /) -> float§
@text_skew_x.setter def text_skew_x(self, /, skew: float) -> None§
@property def textsize(self, /) -> float§
@textsize.setter def textsize(self, /, size: float) -> None§
@property def typeface(self, /) -> Any |None§
@typeface.setter def typeface(self, /, typeface: Any) -> None§
@property def verticaltext(self, /) -> bool§
@verticaltext.setter def verticaltext(self, /, _value: bool) -> None§

Methods§

def break_text(self, /, text: str, max_width: float) -> tuple[int, float]§
def clone(self, /) -> Paint§
def measure_text(self, /, text: str) -> tuple[float, Rect]§