SourceClass Surface
from skia import Surfaceclass Surface:Surface is responsible for managing the pixels that a canvas draws into. The pixels can be
allocated either in CPU memory (a raster surface) or on the GPU (a RenderTarget surface).
Surface takes care of allocating a Canvas that will draw into the surface. Call
Surface.canvas() to use that canvas (but don't delete it, it is owned by the surface).
Surface always has non-zero dimensions. If there is a request for a new surface, and either
of the requested dimensions are zero, then None will be returned.
Properties§
Source@property
def height(self, /) -> int§
Returns pixel row count; may be zero or greater.
Returns: number of pixel rows
Source@property
def width(self, /) -> int§
Returns pixel count in each row; may be zero or greater.
Returns: number of pixel columns
Methods§
Sourcedef canvas(self, /) -> Canvas§
Sourcedef draw(self, /, canvas: Canvas, x: float, y: float, paint: Paint |None = None) -> None§
Draws Surface contents to canvas, with its top-left corner at (offset.x, offset.y).
If Paint paint is not None, apply skia.ColorFilter, alpha, skia.ImageFilter, and skia.BlendMode.
canvas-Canvasdrawn intooffset.x- horizontal offset inCanvas-
offset.y- vertical offset inCanvas -
paint-Paintcontainingskia.BlendMode,skia.ColorFilter,skia.ImageFilter, and so on; orNone
Example (C++): https://fiddle.skia.org/c/@Surface_draw