Canvacord

ImageManipulator

Creates a new CanvasImage instance.

new ImageManipulator(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

brightness(value);

Applies brightness filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

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

circularize(width, height);

Applies a circular clip to the image.

ParameterTypeDescriptionOptional
width

The width of the image

height

The height of the image

Returns:void

contrast(value);

Applies contrast filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

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

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

dropShadow(config);

Applies drop-shadow filter to the image.

ParameterTypeDescriptionOptional
config

The drop-shadow config

encode();

Encodes the canvas to a buffer.

Returns:Promise<Buffer>

erase(x, y, width, height);

Erases a part of the canvas.

ParameterTypeDescriptionOptional
x

The x position to erase

y

The y position to erase

width

The width of the area to erase

height

The height of the area to erase

Returns:void

flip(axis);

Flips the canvas.

ParameterTypeDescriptionOptional
axis
'x''y'

The axis to flip, `x` or `y`.

Returns:void

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

hueRotate(value);

Applies hue-rotate filter to the image.

ParameterTypeDescriptionOptional
value

The degrees to rotate

invert(value);

Applies invert filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

opacity(value);

Applies opacity filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

pixelate([pixels]);

Draws pixelated image to the canvas.

ParameterTypeDescriptionOptional
pixels

The amount of pixels to use

process(canvas, ctx);

Processes the steps and applies them to the canvas.

ParameterTypeDescriptionOptional
canvas
Canvas

The canvas to apply the steps to

ctx
SKRSContext2D

The canvas context to apply the steps to

Returns:Promise<void>

resetTransform();

Resets the transform of the canvas.

Returns:void

restore();

Restores the last saved canvas context state.

rotate(degrees);

Rotates the canvas.

ParameterTypeOptional
degrees

saturate(value);

Applies saturate filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

save();

Saves the canvas context state.

scale(x, y);

Scales the canvas.

ParameterTypeDescriptionOptional
x

The x scale

y

The y scale

Returns:void

sepia(value);

Applies sepia filter to the image.

ParameterTypeDescriptionOptional
value

The filter intensity

transform(a, b, c, d, e, f);

Applies a transform to the canvas.

ParameterTypeOptional
a
b
c
d
e
f
Returns:void

translate(x, y);

Translates the canvas.

ParameterTypeDescriptionOptional
x

The x position to translate

y

The y position to translate

Returns:void