Skip to main content
Home
This package works with Browsers
This package works with Browsers
JSR Score
41%
Published
3 months ago (0.0.6)
class CanvasDrawer
implements Drawer

Constructors

new
CanvasDrawer(context: CanvasRenderingContext2D)

Properties

Methods

addPointToLine(
x: number,
y: number,
stroke?: boolean,
): void
clear(resetTransform?: boolean): void
drawArrow(
_x1: number,
_y1: number,
_x2: number,
_y2: number,
_color?: ColorType,
width?: number,
_arrowWidth?: number,
_arrowLength?: number,
): void
drawCross(
x: number,
y: number,
w: number,
h: number,
color?: ColorType,
width?: number,
): this
drawFullCanvasGrid(
startX: number,
startY: number,
offset: number,
rows: number,
columns: number,
): void
drawImage(
image: CanvasImageSource,
x: number,
y: number,
w?: number,
h?: number,
): void
drawInClearTransform(callback: (drawer: CanvasDrawer) => unknown): void
drawInOffsetTransform(
x: number,
y: number,
callback: (drawer: CanvasDrawer) => unknown,
): void
drawLine(
x1: number,
y1: number,
x2: number,
y2: number,
color?: ColorType,
width?: number,
): void
drawPathWithOffsetAndMultiplier(
points: readonly ReadonlySimpleVector2[],
fillColor?: ColorType,
strokeColor?: ColorType,
offset?: ReadonlySimpleVector2,
multiplier?: number,
strokeWidth?: number,
close?: boolean,
): void

Fill path if fillColor is provided and stroke if strokeColor and strokeWidth are provided

drawRotatedImage(
image: CanvasImageSource,
x: number,
y: number,
w: number,
h: number,
rotation: number,
): void
drawSimpleTexts(
texts: readonly string[],
x: number,
y: number,
textOptions: Omit<TextOptionsInterface, "horizontalAlign" | "verticalAlign">,
): void
drawStaticTextWithinGrid(
texts: readonly string[],
x:
number
| "left"
| "right"
,
y:
number
| "top"
| "bottom"
,
width?: number,
height?: number,
unnamed 5?: Partial<TextOptionsInterface> & { padding?: number; gridFillColor?: Color; gridStrokeColor?: Color; gridStrokeWidth?: number; },
): void
drawText(
text: string,
x: number,
y: number,
w: number,
h: number,
textOptions: TextOptionsInterface,
): void
drawTextSimple(
text: string,
x: number,
y: number,
textOptions: Omit<TextOptionsInterface, "horizontalAlign" | "verticalAlign">,
): void
drawTexts(
texts: readonly string[],
x: number,
y: number,
w: number,
h: number,
textOptions: Omit<TextOptionsInterface, "rotation">,
): void
fillArc(
x: number,
y: number,
w: number,
h: number,
color?: ColorType,
innerRadius?: number,
): void
fillArcByCenter(
cx: number,
cy: number,
w: number,
h: number,
color?: ColorType,
innerRadius?: number,
): void
fillArcByCenterAndRadius(
cx: number,
cy: number,
radius: number,
color?: ColorType,
innerRadius?: number,
): void
fillDots(
points: readonly ReadonlyPair<number>[],
color: ColorType,
radius: number,
): this
fillPath(
points: readonly ReadonlySimpleVector2[],
color?: ColorType,
): void
fillPathWithOffset(
points: readonly ReadonlySimpleVector2[],
color?: ColorType,
offset?: ReadonlySimpleVector2,
): void
fillPolygon(
points: readonly ReadonlyPair<number>[],
color?: ColorType,
): void
fillRect(
x: number,
y: number,
w: number,
h: number,
color?: ColorType,
): this
fillRectWithHole(
x: number,
y: number,
outerWidth: number,
outerHeight: number,
innerX: number,
innerY: number,
innerWidth: number,
innerHeight: number,
fillColor: string,
): void
fillRectangles(
data: [][],
color?: ColorType,
): void
fillRotatedArc(
x: number,
y: number,
w: number,
h: number,
angle: number,
color?: ColorType,
innerRadius?: number,
): void
fillRotatedRect(
x: number,
y: number,
w: number,
h: number,
angle: number,
color?: ColorType,
): void
private
fillRotatedText(
text: string,
x: number,
y: number,
angle?: number,
maxWidth?: number,
): void
fillRoundedRect(
x: number,
y: number,
w: number,
h: number,
round: RoundData,
color?: ColorType,
): void
fillText(
text: string,
x: number,
y: number,
maxWidth?: number,
): void
fillVerticalText(
text: string,
x: number,
y: number,
maxWidth?: number,
): void
fullCanvasGrid(
startX: number,
startY: number,
offset: number,
rows: number,
columns: number,
): void
horizontalLine(
y: number,
startX?: number,
endX?,
): void
horizontalLines(
startY: number,
offsetY: number,
steps: number,
startX?: number,
endX?,
): void
private
makeGrid(
blocks: ReadonlySimpleVector2,
blockSize: SizeType,
offset?: ReadonlySimpleVector2,
): void
show(format?: string): void
strokeArc(
x: number,
y: number,
w: number,
h: number,
color?: ColorType,
width?: number,
): void
strokeArcByCenter(
cx: number,
cy: number,
w: number,
h: number,
color?: ColorType,
width?: number,
): void
strokeArcByCenterAndRadius(
cx: number,
cy: number,
radius: number,
color?: ColorType,
width?: number,
): void
strokeGrid(
blocks: ReadonlySimpleVector2,
blockSize: SizeType,
color?: ColorType,
width?: number,
offset?: ReadonlySimpleVector2,
): void
strokeLine(
points: readonly ReadonlySimpleVector2[],
color?: ColorType,
width?: number,
): this
strokePath(
points: readonly ReadonlySimpleVector2[],
color?: ColorType,
width?,
close?: boolean,
): void
strokePathWithOffset(
points: readonly ReadonlySimpleVector2[],
color?: ColorType,
offset?: ReadonlySimpleVector2,
width?,
close?: boolean,
): void
strokePolygon(
points: readonly ReadonlyPair<number>[],
color?: ColorType,
width?: number,
): void
strokePolyline(
points: readonly ReadonlyPair<number>[],
color?: ColorType,
width?: number,
): this
strokeRect(
x: number,
y: number,
w: number,
h: number,
color?: ColorType,
width?: number,
): void
strokeRectVec(
position: ReadonlySimpleVector2,
size: ReadonlySimpleVector2,
color?: ColorType,
width?: number,
): void
strokeRectangles(
data: [][],
color?: ColorType,
width?: number,
): void
strokeRotatedArc(
x: number,
y: number,
w: number,
h: number,
angle: number,
color?: ColorType,
width?: number,
): void
strokeRotatedRect(
x: number,
y: number,
w: number,
h: number,
angle: number,
color?: ColorType,
width?: number,
): void
strokeRoundedRect(
x: number,
y: number,
w: number,
h: number,
round: RoundData,
color?: ColorType,
width?: number,
): void
toUrl(format?: string): string
verticalLine(
x: number,
startY?: number,
endY?,
): void
verticalLines(
startX: number,
offsetX: number,
steps: number,
startY?: number,
endY?,
): void

Static Methods

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.