import { type Canvas } from "https://deno.land/x/canvas@v1.3.0/mod.ts";
See SkCanvas.h for more information on this class.
Methods
Fills the current clip with the given color using Src BlendMode. This has the effect of replacing all pixels contained by clip with color.
Replaces clip with the intersection or difference of the current clip and path, with an aliased or anti-aliased clip edge.
Replaces clip with the intersection or difference of the current clip and rect, with an aliased or anti-aliased clip edge.
Replaces clip with the intersection or difference of the current clip and rrect, with an aliased or anti-aliased clip edge.
Replaces current matrix with m premultiplied with the existing matrix.
Draws arc using clip, Matrix, and Paint paint.
Arc is part of oval bounded by oval, sweeping from startAngle to startAngle plus sweepAngle. startAngle and sweepAngle are in degrees.
Draws a set of sprites from atlas, using clip, Matrix, and optional Paint paint.
Fills clip with the given color.
Draws RRect outer and inner using clip, Matrix, and Paint paint. outer must contain inner or the drawing is undefined.
Draws a run of glyphs, at corresponding positions, in a given font.
Draws the given image with its top-left corner at (left, top) using the current clip, the current matrix, and optionally-provided paint.
Draws the given image with its top-left corner at (left, top) using the current clip, the current matrix. It will use the cubic sampling options B and C if necessary.
Draws the given image with its top-left corner at (left, top) using the current clip, the current matrix. It will use the provided sampling options if necessary.
Draws the provided image stretched proportionally to fit into dst rectangle. The center rectangle divides the image into nine sections: four sides, four corners, and the center.
Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle.
Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle. It will use the cubic sampling options B and C if necessary.
Draws sub-rectangle src from provided image, scaled and translated to fill dst rectangle. It will use the provided sampling options if necessary.
Draws line segment from (x0, y0) to (x1, y1) using the current clip, current matrix, and the provided paint.
Draws an oval bounded by the given rectangle using the current clip, current matrix, and the provided paint.
Fills clip with the given paint.
Draws the given Paragraph at the provided coordinates. Requires the Paragraph code to be compiled in.
Draws the given path using the current clip, current matrix, and the provided paint.
Draws a cubic patch defined by 12 control points [top, right, bottom, left] with optional colors and shader-coordinates [4] specifed for each corner [top-left, top-right, bottom-right, bottom-left]
Draws the given picture using the current clip, current matrix, and the provided paint.
Draws the given points using the current clip, current matrix, and the provided paint.
See Canvas.h for more on the mode and its interaction with paint.
Draws the given rectangle using the current clip, current matrix, and the provided paint.
Draws the given rectangle using the current clip, current matrix, and the provided paint.
Draws the given rectangle with rounded corners using the current clip, current matrix, and the provided paint.
Draw an offset spot shadow and outlining ambient shadow for the given path using a disc light. See SkShadowUtils.h for more details
Draw the given text at the location (x, y) using the provided paint and font. The text will be drawn as is; no shaping, left-to-right, etc.
Draws the given TextBlob at (x, y) using the current clip, current matrix, and the provided paint. Reminder that the fonts used to draw TextBlob are part of the blob.
Draws the given vertices (a triangle mesh) using the current clip, current matrix, and the provided paint. If paint contains an Shader and vertices does not contain texCoords, the shader is mapped using the vertices' positions. If vertices colors are defined in vertices, and Paint paint contains Shader, BlendMode mode combines vertices colors with Shader.
Returns the 4x4 matrix matching the given marker or null if there was none. See also markCTM.
Returns the current transform from local coordinates to the 'device', which for most purposes means pixels.
Returns the number of saved states, each containing: Matrix and clip. Equals the number of save() calls less the number of restore() calls plus one. The save count of a new canvas is one.
Legacy version of getLocalToDevice(), which strips away any Z information, and just returns a 3x3 version.
Creates Surface matching info and props, and associates it with Canvas. Returns null if no match found.
Record a marker (provided by caller) for the current CTM. This does not change anything about the ctm or clip, but does "name" this matrix value, so it can be referenced by custom effects (who access it by specifying the same name). See also findMarkedCTM.
Returns a TypedArray containing the pixels reading starting at (srcX, srcY) and does not exceed the size indicated by imageInfo. See SkCanvas.h for more on the caveats.
If dest is not provided, we allocate memory equal to the provided height * the provided bytesPerRow to fill the data with.
This is generally a very expensive call for the GPU backend.
Removes changes to the current matrix and clip since Canvas state was last saved. The state is removed from the stack. Does nothing if the stack is empty.
Saves Matrix and clip, and allocates a SkBitmap for subsequent drawing. Calling restore() discards changes to Matrix and clip, and draws the SkBitmap. It returns the height of the stack. See Canvas.h for more.
Scales the current matrix by sx on the x-axis and sy on the y-axis.
Skews Matrix by sx on the x-axis and sy on the y-axis. A positive value of sx skews the drawing right as y-axis values increase; a positive value of sy skews the drawing down as x-axis values increase.
Translates Matrix by dx along the x-axis and dy along the y-axis.
Writes the given rectangle of pixels to the provided coordinates. The source pixels will be converted to the canvas's alphaType and colorType if they do not match.