ig.

utilsdraw

Static utilities for drawing.

Author:
  • Collin Hover - collinhover.com
Source:

<static> fillPolygon(context, vertices, offsetX, offsetY, scale)

Fills a polygon defined by vertices in context. IMPORTANT: this method assumes the context's fillStyle is already set!

Parameters:
Name Type Argument Default Description
context CanvasRenderingContext2D context to draw into.
vertices Array polygon vertices.
offsetX Number <optional>
0 x offset.
offsetY Number <optional>
0 y offset.
scale Number <optional>
1 scale after offset.
Source:

<static> fillRoundedRect(context, x, y, width, height, radius)

Fills a rounded rectangle in context. IMPORTANT: this method assumes the context's fillStyle is already set!

Parameters:
Name Type Description
context CanvasRenderingContext2D
x Number top left x position
y Number top left y position
width Number rect width
height Number rect height
radius Number corner radius
Source:

<static> pixelFillPolygon(context, minX, minY, maxX, maxY, vertices, r, g, b, a, add, boundsVertices, stabilize)

Pixel perfectly fills a polygon defined by vertices in context with r, g, b, a (optionally, add color instead of set color).

Parameters:
Name Type Argument Default Description
context CanvasRenderingContext2D context to draw into.
minX Number left position of bounds
minY Number top position of bounds
maxX Number right position of bounds
maxY Number bottom position of bounds
vertices Array polygon vertices, in absolute or relative coordinates.
r Number red.
g Number green.
b Number blue.
a Number alpha.
add Boolean <optional>
false add to existing color.
boundsVertices Object <optional>
boundsContext bounds of polygon.
stabilize Boolean <optional>
true whether to stabilize for rounding error.
Source:

<static> pixelFillRoundedRect(context, boundsContext, minX, minY, maxX, maxY, x, y, width, height, radius, r, g, b, a, precision, add, stabilize)

Pixel perfectly fills a rounded rectangle in context.

Parameters:
Name Type Argument Default Description
context CanvasRenderingContext2D
boundsContext Object bounds of context to draw into.
minX Number left position of bounds
minY Number top position of bounds
maxX Number right position of bounds
maxY Number bottom position of bounds
x Number top left x position
y Number top left y position
width Number rect width
height Number rect height
radius Number corner radius
r Number red.
g Number green.
b Number blue.
a Number alpha.
precision Number <optional>
dynamic precision of curves in number of vertices.
add Boolean <optional>
false add to existing color.
stabilize Boolean <optional>
true whether to stabilize for rounding error.
Source: