Canvacord

CanvasImage

Creates a new CanvasImage instance.

new CanvasImage(source, [width], [height])
ParameterTypeDescriptionOptional
source

The image source

width

The width of the image

height

The height of the image

Properties

height

The height of the canvas

Type:number

source

The image source

steps

The steps to apply to the canvas.

width

The width of the canvas

Type:number

Methods

blur(value);

Applies blur filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

brightness(value);

Applies brightness filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

circle([width], [height]);

Draws the image to the canvas with a circle clip.

ParameterTypeDescriptionOptional
width

The width of the image

height

The height of the image

Returns:CanvasImage

contrast(value);

Applies contrast filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

draw(x, y, [width], [height]);

Draws the image to the canvas.

ParameterTypeDescriptionOptional
x

The x position to draw the image

y

The y position to draw the image

width

The width of the image

height

The height of the image

Returns:CanvasImage

drawImage(image, x, y, [width], [height]);

Draws the image to the canvas.

ParameterTypeDescriptionOptional
image

The image to draw

x

The x position to draw the image

y

The y position to draw the image

width

The width of the image

height

The height of the image

Returns:CanvasImage

dropShadow(config);

Applies drop-shadow filter to the image.

ParameterTypeDescriptionOptional
config

The drop-shadow config

Returns:CanvasImage

encode();

Encodes the canvas to a buffer.

Returns:Promise<Buffer>

getFinalCanvas();

Returns the canvas instance by applying the steps.

Returns:Promise<Canvas>

grayscale(value);

Applies grayscale filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

hueRotate(value);

Applies hue-rotate filter to the image.

ParameterTypeDescriptionOptional
value

The degrees to rotate

Returns:CanvasImage

invert(value);

Applies invert filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

opacity(value);

Applies opacity filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

pixelate([pixels]);

Draws pixelated image to the canvas.

ParameterTypeDescriptionOptional
pixels

The amount of pixels to use

Returns:CanvasImage

process(canvas, ctx);

Renders the applied filters to the canvas.

ParameterTypeDescriptionOptional
canvas
Canvas

The canvas to render the filters to

ctx
SKRSContext2D

The canvas context

Returns:Promise<void>

restore();

Restores the last saved canvas context state.

Returns:CanvasImage

saturate(value);

Applies saturate filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage

save();

Saves the canvas context state.

Returns:CanvasImage

sepia(value);

Applies sepia filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

Returns:CanvasImage