Canvas.fill() - newo2001/HTML5-Canvas-Wrapper GitHub Wiki

Description

Changes the color that the canvas will use for future drawing operations.

Syntax

canvas.fill(color);

canvas (Canvas)

The instance of the Canvas class to be affected.

color (Vec4, Vec3)

The color to use for future drawing operations represented as a Vec4 where the vector's (x, y, z, w) components are the color's (r, g, b, a) values respectively.
A Vec3 can also be used, this is then casted to a Vec4 with a default w-value of 255 making it completely opaque.

Example

let canvas = new Canvas(new Vec2(50, 50), new Vec2(100, 200));

canvas.fill(new Vec3(255, 0, 0));
Will make future drawing operations use the color red.

Notes

  • This function updates the color field of the canvas.
    If you know what you're doing you can also update the color field manually.
⚠️ **GitHub.com Fallback** ⚠️