CanvasRenderingContext2D class abstract
Provides 2D rendering methods for the <canvas> element.
See: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
- Implemented types
Constructors
Properties
- canvas → HTMLCanvasElement
-
The canvas element this context draws on.
no setterinherited
- fillStyle ↔ Object
-
Current fill style (CSS color string, CanvasGradient, or CanvasPattern).
getter/setter pair
- font ↔ String
-
CSS font string for text methods (e.g.,
'16px sans-serif').getter/setter pair - globalAlpha ↔ double
-
Global alpha (transparency), from 0.0 to 1.0.
getter/setter pair
- globalCompositeOperation ↔ String
-
Compositing operation (e.g.,
'source-over','multiply').getter/setter pair - hashCode → int
-
The hash code for this object.
no setterinherited
- lineCap ↔ String
-
Shape of line ends:
'butt','round', or'square'.getter/setter pair - lineDashOffset ↔ double
-
Line dash offset. Default:
0.0.getter/setter pair - lineJoin ↔ String
-
Shape of line joins:
'round','bevel', or'miter'.getter/setter pair - lineWidth ↔ double
-
Width of lines. Default:
1.0.getter/setter pair - miterLimit ↔ double
-
Miter limit ratio.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shadowBlur ↔ double
-
Blur amount for shadows.
getter/setter pair
- shadowColor ↔ String
-
Color of shadows (CSS color string).
getter/setter pair
- shadowOffsetX ↔ double
-
Horizontal offset for shadows.
getter/setter pair
- shadowOffsetY ↔ double
-
Vertical offset for shadows.
getter/setter pair
- strokeStyle ↔ Object
-
Current stroke style (CSS color string, CanvasGradient, or CanvasPattern).
getter/setter pair
- textAlign ↔ String
-
Text alignment:
'start','end','left','right','center'.getter/setter pair - textBaseline ↔ String
-
Text baseline:
'top','hanging','middle','alphabetic','ideographic','bottom'.getter/setter pair
Methods
-
arc(
num x, num y, num radius, num startAngle, num endAngle, [bool counterclockwise = false]) → void - Adds a circular arc to the current path.
-
arcTo(
num x1, num y1, num x2, num y2, num radius) → void - Adds an arc between two tangent lines.
-
beginPath(
) → void - Starts a new path.
-
bezierCurveTo(
num cp1x, num cp1y, num cp2x, num cp2y, num x, num y) → void - Adds a cubic Bézier curve.
-
clearRect(
num x, num y, num width, num height) → void - Clears a rectangular area, making it fully transparent.
-
clip(
) → void - Clips the current path, making it the clipping region.
-
closePath(
) → void - Closes the current sub-path.
-
createImageData(
int sw, int sh) → ImageData - Creates a new blank ImageData with the given dimensions.
-
drawImage(
Element image, num dx, num dy) → void - Draws an image onto the canvas.
-
drawImageScaled(
Element image, num dx, num dy, num dWidth, num dHeight) → void - Draws an image scaled to the given dimensions.
-
drawImageScaledFromSource(
Element image, num sx, num sy, num sWidth, num sHeight, num dx, num dy, num dWidth, num dHeight) → void - Draws a portion of an image onto a portion of the canvas.
-
ellipse(
num x, num y, num radiusX, num radiusY, num rotation, num startAngle, num endAngle, [bool counterclockwise = false]) → void - Adds an elliptical arc to the current path.
-
fill(
) → void - Fills the current path.
-
fillRect(
num x, num y, num width, num height) → void - Draws a filled rectangle.
-
fillText(
String text, num x, num y, [num? maxWidth]) → void - Draws filled text.
-
getImageData(
int sx, int sy, int sw, int sh) → ImageData - Returns an ImageData object representing pixel data for a rectangle.
-
getLineDash(
) → List< num> - Returns the current line dash pattern.
-
lineTo(
num x, num y) → void - Connects the last point to the given point with a straight line.
-
measureText(
String text) → TextMetrics - Returns metrics for the given text string.
-
moveTo(
num x, num y) → void - Moves the starting point of a new sub-path.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
putImageData(
ImageData imagedata, int dx, int dy) → void - Paints pixel data from an ImageData object onto the canvas.
-
quadraticCurveTo(
num cpx, num cpy, num x, num y) → void - Adds a quadratic Bézier curve.
-
rect(
num x, num y, num width, num height) → void - Adds a rectangle to the current path.
-
resetTransform(
) → void - Resets the current transform to the identity matrix.
-
restore(
) → void - Restores the most recently saved drawing state.
-
rotate(
num angle) → void - Rotates the canvas.
-
save(
) → void - Saves the current drawing state to a stack.
-
scale(
num x, num y) → void - Scales the canvas units.
-
setLineDash(
List< num> segments) → void - Sets the current line dash pattern.
-
setTransform(
num a, num b, num c, num d, num e, num f) → void - Resets the current transform and then applies the given matrix.
-
stroke(
) → void - Strokes (outlines) the current path.
-
strokeRect(
num x, num y, num width, num height) → void - Draws a rectangle outline.
-
strokeText(
String text, num x, num y, [num? maxWidth]) → void - Draws text outlines.
-
toString(
) → String -
A string representation of this object.
inherited
-
translate(
num x, num y) → void - Translates the canvas origin.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited