S or /

SourceClass Surface

from skia import Surface
class 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§

Returns Canvas that draws into Surface. Subsequent calls return the same Canvas. Canvas returned is managed and owned by Surface, and is deleted when Surface is deleted.

Returns: drawing Canvas for Surface

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

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.

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

def get_props(self, /) -> SurfaceProps§
def snapshot(self, /) -> Image§
def write_file(self, /, path: Any) -> None§