Vector2

clay. Vector2

# new Vector2(x, y)

Source:
Parameters:
Name Type Description
x number
y number

Members

# _dirty :boolean

Source:

Dirty flag is used by the Node to determine if the matrix is updated to latest

Type:
  • boolean

# array :Float32Array

Source:

Storage of Vector2, read and write of x, y will change the values in array All methods also operate on the array instead of x, y components

Type:
  • Float32Array

# x :number

Source:
Type:
  • number

# y :number

Source:
Type:
  • number

Methods

# add(b) → {clay.Vector2}

Source:

Add b to self

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# clone() → {clay.Vector2}

Source:

Clone a new Vector2

Returns:
Type
clay.Vector2

# copy(b) → {clay.Vector2}

Source:

Copy x, y from b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# cross(out, b) → {clay.Vector2}

Source:

Cross product of self and b, written to a Vector3 out

Parameters:
Name Type Description
out clay.Vector3
b clay.Vector2
Returns:
Type
clay.Vector2

# dist(b) → {number}

Source:

Alias for distance

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
number

# distance(b) → {number}

Source:

Distance between self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
number

# div(b) → {clay.Vector2}

Source:

Alias for divide

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# divide(b) → {clay.Vector2}

Source:

Divide self by b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# dot(b) → {number}

Source:

Dot product of self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
number

# len() → {number}

Source:

Alias of length

Returns:
Type
number

# length() → {number}

Source:

Calculate the length

Returns:
Type
number

# lerp(a, b, t) → {clay.Vector2}

Source:

Linear interpolation between a and b

Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
t number
Returns:
Type
clay.Vector2

# max(b) → {clay.Vector2}

Source:

Maximum of self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# min(b) → {clay.Vector2}

Source:

Minimum of self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# mul(b) → {clay.Vector2}

Source:

Alias for multiply

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# multiply(b) → {clay.Vector2}

Source:

Mutiply self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# negate() → {clay.Vector2}

Source:

Negate self

Returns:
Type
clay.Vector2

# normalize() → {clay.Vector2}

Source:

Normalize self

Returns:
Type
clay.Vector2

# random(scale) → {clay.Vector2}

Source:

Generate random x, y components with a given scale

Parameters:
Name Type Description
scale number
Returns:
Type
clay.Vector2

# scale(scale) → {clay.Vector2}

Source:

Scale self

Parameters:
Name Type Description
scale number
Returns:
Type
clay.Vector2

# scaleAndAdd(b, scale) → {clay.Vector2}

Source:

Scale b and add to self

Parameters:
Name Type Description
b clay.Vector2
scale number
Returns:
Type
clay.Vector2

# set(x, y) → {clay.Vector2}

Source:

Set x and y components

Parameters:
Name Type Description
x number
y number
Returns:
Type
clay.Vector2

# setArray(arr) → {clay.Vector2}

Source:

Set x and y components from array

Parameters:
Name Type Description
arr Float32Array | Array.<number>
Returns:
Type
clay.Vector2

# sqrDist(b) → {number}

Source:

Alias for squaredDistance

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
number

# sqrLen() → {number}

Source:

Alias for squaredLength

Returns:
Type
number

# squaredDistance(b) → {number}

Source:

Squared distance between self and b

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
number

# squaredLength() → {number}

Source:

Squared length of self

Returns:
Type
number

# sub(b) → {clay.Vector2}

Source:

Alias for subtract

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# subtract(b) → {clay.Vector2}

Source:

Subtract b from self

Parameters:
Name Type Description
b clay.Vector2
Returns:
Type
clay.Vector2

# transformMat2(m) → {clay.Vector2}

Source:

Transform self with a Matrix2 m

Parameters:
Name Type Description
m clay.Matrix2
Returns:
Type
clay.Vector2

# transformMat2d(m) → {clay.Vector2}

Source:

Transform self with a Matrix2d m

Parameters:
Name Type Description
m clay.Matrix2d
Returns:
Type
clay.Vector2

# transformMat3(m) → {clay.Vector2}

Source:

Transform self with a Matrix3 m

Parameters:
Name Type Description
m clay.Matrix3
Returns:
Type
clay.Vector2

# transformMat4(m) → {clay.Vector2}

Source:

Transform self with a Matrix4 m

Parameters:
Name Type Description
m clay.Matrix4
Returns:
Type
clay.Vector2

# (static) add(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) copy(out, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) cross(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector3
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) dist(a, b) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
Returns:
Type
number

# (static) distance(a, b) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
Returns:
Type
number

# (static) div(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) divide(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) dot(a, b) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
Returns:
Type
number

# (static) len(a) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
Returns:
Type
number

# (static) lerp(out, a, b, t) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
t number
Returns:
Type
clay.Vector2

# (static) max(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) min(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) mul(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) multiply(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) negate(out, a) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
Returns:
Type
clay.Vector2

# (static) normalize(out, a) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
Returns:
Type
clay.Vector2

# (static) random(out, scale) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
scale number
Returns:
Type
clay.Vector2

# (static) scale(out, a, scale) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
scale number
Returns:
Type
clay.Vector2

# (static) scaleAndAdd(out, a, b, scale) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
scale number
Returns:
Type
clay.Vector2

# (static) set(out, x, y) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
x number
y number
Returns:
Type
clay.Vector2

# (static) sqrDist(a, b) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
Returns:
Type
number

# (static) sqrLen(a) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
Returns:
Type
number

# (static) squaredDistance(a, b) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
b clay.Vector2
Returns:
Type
number

# (static) squaredLength(a) → {number}

Source:
Parameters:
Name Type Description
a clay.Vector2
Returns:
Type
number

# (static) sub(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) subtract(out, a, b) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
b clay.Vector2
Returns:
Type
clay.Vector2

# (static) transformMat2(out, a, m) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
m clay.Matrix2
Returns:
Type
clay.Vector2

# (static) transformMat2d(out, a, m) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
m clay.Matrix2d
Returns:
Type
clay.Vector2

# (static) transformMat3(out, a, m) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
m Matrix3
Returns:
Type
clay.Vector2

# (static) transformMat4(out, a, m) → {clay.Vector2}

Source:
Parameters:
Name Type Description
out clay.Vector2
a clay.Vector2
m clay.Matrix4
Returns:
Type
clay.Vector2