Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/canvas/src/canvaskit.ts>Surface

Canvas API for Deno, ported from canvaskit-wasm (Skia).
Go to Latest
interface Surface
implements EmbindObject<Surface>
import { type Surface } from "https://deno.land/x/canvas@v1.3.0/src/canvaskit.ts";

Methods

dispose(): void

Clean up the surface and any extra memory. [Deprecated]: In the future, calls to delete() will be sufficient to clean up the memory.

flush(): void

Make sure any queued draws are sent to the screen or the GPU.

getCanvas(): Canvas

Return a canvas that is backed by this surface. Any draws to the canvas will (eventually) show up on the surface. The returned canvas is owned by the surface and does NOT need to be cleaned up by the client.

height(): number

Returns the height of this surface in pixels.

imageInfo(): ImageInfo

Returns the ImageInfo associated with this surface.

makeImageFromTexture(tex: any, info: ImageInfo): Image | null

Creates an Image from the provided texture and info. The Image will own the texture; when the image is deleted, the texture will be cleaned up.

makeImageFromTextureSource(
width?: number,
height?: number,
): Image | null

Returns a texture-backed image based on the content in src. It uses RGBA_8888, unpremul and SRGB - for more control, use makeImageFromTexture.

Not available for software-backed surfaces.

makeImageSnapshot(bounds?: InputIRect): Image

Returns current contents of the surface as an Image. This image will be optimized to be drawn to another surface of the same type. For example, if this surface is backed by the GPU, the returned Image will be backed by a GPU texture.

makeSurface(info: ImageInfo): Surface

Returns a compatible Surface, haring the same raster or GPU properties of the original. The pixels are not shared.

reportBackendTypeIsGPU(): boolean

Returns if this Surface is a GPU-backed surface or not.

sampleCnt(): number

If this surface is GPU-backed, return the sample count of the surface.

width(): number

Returns the width of this surface in pixels.