Global

Members

(constant) version :String

The version of the library

Source:
Type:
  • String

Methods

compVersions(v1, v2) → {Number}

Used to compare two versions of the library

Source:
Parameters:
Name Type Description
v1 String

The version that the return value is based on

v2 String

The version to compare the first one to

Returns:
Type:
Number
  • -1 if v1 is lower than v2;
  • 0 if v1 is equal to v2;
  • 1 if v1 is higher than v2.

formatString(str, …formatsopt) → {String}

Formats a string by replacing {i} with formats[i]

Source:
Parameters:
Name Type Attributes Description
str String

The string to format

formats any <optional>
<repeatable>

The things to replace {i} with

Returns:
Type:
String

The formatted string

Example
formatString("const {0} = {1};", "variableName", "value") => "const variableName = value;"

generateUUID() → {Number}

Generates an UUID used for all auto generated stuff from this library

Source:
Returns:
Type:
Number

An UUID within the library

Type Definitions

Alignment

Alignment options

Properties:
Name Type Attributes Description
horizontal "left" | "center" | "right" <optional>

Where the origin of the shape should be relative to it horizontally

vertical "top" | "center" | "bottom" <optional>

Where the origin of the shape should be relative to it vertically

Source:
Type:
  • Object

ColorType

An Object containing info about a Color's type (Used for Color.getType)

Properties:
Name Type Description
type "Color" | "rgb" | "hex" | "css" | "grayscale" | "unknown"

The type of the Color

isValid Boolean

Whether or not the Color is valid

Source:
Type:
  • Object

PathConfig

Paths' config

Properties:
Name Type Attributes Description
noStroke Boolean <optional>

Whether or not stroke should be applied

noFill Boolean <optional>

Whether or not the shape should be filled

noClose Boolean <optional>

Whether or not the path should be closed

round Boolean <optional>

Whether or not corners should be round

Source:
Type:
  • Object

RectConfig

Rectangles' config

Properties:
Properties
Name Type Attributes Description
noStroke Boolean <optional>

Whether or not stroke should be applied

noFill Boolean <optional>

Whether or not the shape should be filled

alignment Alignment <optional>

Specifies the position of the origin of the rectangle

rounded Object <optional>

If not undefined the rectangle will be drawn as if it has round corners and its x and y will be the center of it

Name Type Attributes Description
corners Array.<Boolean> <optional>

Corners that should be drawn (clockwise starting from the top-left one), if undefined all corners will be drawn

radiusMode "percentage" | "pixels" <optional>

How RectConfig#rounded.radius should be handled, if undefined it defaults to "percentage".
"percentage": Takes the smallest between the width and the height and uses it to calculate the radius of the corner in pixels;
"pixels": It uses the specified number as the radius.

radius Number <optional>

Its behaviour depends on RectConfig#rounded.radiusMode

Source:
Type:
  • Object

RGBColor

An RGB Color that could include Alpha (An Array of 3/4 Numbers)

Source:
Type:
  • Array.<Number>

ShapeConfig

Shapes' config

Properties:
Name Type Attributes Description
noStroke Boolean <optional>

Whether or not stroke should be applied

noFill Boolean <optional>

Whether or not the shape should be filled

Source:
Type:
  • Object

TextConfig

Texts' config

Properties:
Name Type Attributes Description
alignment Alignment <optional>

Specifies the position of the origin of the text

noStroke Boolean <optional>

Whether or not stroke should be applied

noFill Boolean <optional>

Whether or not the shape should be filled

maxWidth Number <optional>

Text's max width

returnWidth Boolean <optional>

Whether or not to return text's width after it was drawn

Source:
Type:
  • Object

Vec2Object

An object representation of a 2D Vector

Properties:
Name Type Description
x Number

The x component of the Vector

y Number

The y component of the Vector

Source:
Type:
  • Object

wCanvas_onDraw(canvas, deltaTime) → {undefined}

Source:
Parameters:
Name Type Description
canvas wCanvas

The canvas it's attached to

deltaTime Number

The time elapsed between frames in seconds

Returns:
Type:
undefined

wCanvas_onResize(canvas, targetWidth, targetHeight) → {undefined}

Source:
Parameters:
Name Type Description
canvas wCanvas

The canvas it's attached to

targetWidth Number

The width that this canvas should have

targetHeight Number

The height that this canvas should have

Returns:
Type:
undefined

wCanvas_onSetup(canvas) → {undefined}

Source:
Parameters:
Name Type Description
canvas wCanvas

The canvas it's attached to

Returns:
Type:
undefined

wCanvasConfig

wCanvas's config

Properties:
Name Type Attributes Description
id String <optional>

The id of the canvas you want to wrap

canvas HTMLCanvasElement <optional>

The canvas you want to wrap

width Number <optional>

The desired width of the canvas if onResize is undefined

height Number <optional>

The desired height of the canvas if onResize is undefined

onResize wCanvas_onResize <optional>

Called when canvas needs to be resized

onSetup wCanvas_onSetup <optional>

Called when canvas is fully initialized

onDraw wCanvas_onDraw <optional>

Called every frame

targetFPS Number <optional>

The FPS target of the canvas (If negative it will draw every time the browser lets it)

Source:
Type:
  • Object