@feds01/graphika / core/drawing
core/drawing
Classes
default
Defined in: core/drawing.ts:28
Utility class for drawing items on the canvas.
Constructors
Constructor
new default(
canvas,
context,
options): default;Defined in: core/drawing.ts:29
Parameters
| Parameter | Type |
|---|---|
canvas | HTMLCanvasElement |
context | CanvasRenderingContext2D |
options | DrawerOptions |
Returns
Accessors
ctx
Get Signature
get ctx(): CanvasRenderingContext2D;Defined in: core/drawing.ts:129
Returns
CanvasRenderingContext2D
height
Get Signature
get height(): number;Defined in: core/drawing.ts:125
Returns
number
width
Get Signature
get width(): number;Defined in: core/drawing.ts:121
Returns
number
Methods
_coordinateSafetyCheck()
_coordinateSafetyCheck(x, y): void;Defined in: core/drawing.ts:35
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
Returns
void
circle()
circle(
x,
y,
rad): void;Defined in: core/drawing.ts:40
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
rad | number |
Returns
void
horizontalLine()
horizontalLine(
x,
y,
len): void;Defined in: core/drawing.ts:50
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
len | number |
Returns
void
text()
text(
text,
x,
y,
size,
colour,
alignment): void;Defined in: core/drawing.ts:109
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
text | string | undefined | the actual label |
x | number | undefined | x-coordinate of where to draw the string |
y | number | undefined | x-coordinate of where to draw the string |
size | number | undefined | The font size of the text |
colour | string | undefined | RGBA style colour string |
alignment | CanvasTextAlign | "center" | One of the specified alignments for text |
Returns
void
nothing, just changes the drawing context
Since
v0.0.1 Function to draw text on the canvas at a given location with a particular colour and alignment.
toTextMode()
toTextMode(
size,
colour,
alignment): void;Defined in: core/drawing.ts:84
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
size | number | undefined | The font size of the text |
colour | string | config.axisColour | RGBA style colour string |
alignment | CanvasTextAlign | "center" | One of the specified alignments for text |
Returns
void
nothing, just changes the drawing context
Since
v0.0.1 This simply switches the canvas context to be text mode ready, set the font size and style, set text alignment to middle, and change stroke colour to the axis' colour.
verticalLine()
verticalLine(
x,
y,
len): void;Defined in: core/drawing.ts:61
Parameters
| Parameter | Type |
|---|---|
x | number |
y | number |
len | number |
Returns
void
Type Aliases
CanvasTextAlign
type CanvasTextAlign = "center" | "end" | "left" | "right" | "start";Defined in: core/drawing.ts:23