API Docs for: v2.1.0
Show:

CGSGDimension Class

Extends CGSGVector2D
Module: Util

A Dimension object

Constructor

CGSGDimension

(
  • width
  • height
)

Parameters:

Methods

add

(
  • vector
)
public

returns a new vector added to the value passed in parameter

Parameters:

addEquals

(
  • vector
)
public

add to this vector, the value passed in parameter

Parameters:

copy

() CGSGDimension

Inherited from CGSGVector2D but overwritten in src\utils\class.region.js:246

Return a new object with these attributes

Returns:

cross

() public

Get cross product of this vector and another vector

divide

(
  • vector
)
public

return a new vector divided by the value passed in parameter

Parameters:

divideByFloat

(
  • f
)
public

Divide x and y by f

Parameters:

divideByFloatEquals

(
  • f
)
public

Divide x and y by f

Parameters:

divideEquals

(
  • vector
)
public

divide to this vector, the value passed in parameter

Parameters:

dot

() public

Get dot product of this vector and another vector

getDistance

(
  • vector
)
Number public

Compute the euclidian distance between this vector and the one passe in parameter

Parameters:

Returns:

getLength

() Number public

Returns:

getSquaredLength

() Number public

Returns:

isEmpty

() Boolean

Return true if no pixels are inside the dimension

Returns:

multiply

(
  • vector
)
public

returns a new vector multiplied to the value passed in parameter

Parameters:

multiplyByFloat

(
  • f
)
public

Multiply x and y by f

Parameters:

multiplyByFloatEquals

(
  • f
)
public

Multiply x and y by f

Parameters:

multiplyEquals

(
  • vector
)
public

multiply to this vector, the value passed in parameter

Parameters:

normalize

() public

Normalize this vector

perp

() public

Get a perpendicular vector of this vector

perpendicular

() public

Get a vector perpendicular to this vector and another vector

project

() public

Get a projected vector of this vector and another vector

resizeBy

(
  • widthFactor
  • heightFactor
)

Multiply current dimension by these new ones

Parameters:

resizeTo

(
  • newWidth
  • newHeight
)

Replace current dimension by these new ones

Parameters:

resizeWith

(
  • width
  • height
)

Increase/decrease current dimension with adding values

Parameters:

rotate

(
  • angle
)
public

rotate this vector around its origin

Parameters:

sign

() public

Determines if a given vector is to the right or left of this vector.

subtract

(
  • vector
)
public

returns a new vector subtracted from the value passed in parameter

Parameters:

subtractEquals

(
  • vector
)
public

subtract to this vector, the value passed in parameter

Parameters:

toString

() public

Get a string representing this vector

unit

() public

Get unit vector of this vector and another vector

unitEquals

() public

Get unit vector of this vector and another vector

unitFast

() public

Get approximation of unit vector of this vector and another vector

Properties

height

Number

Alias to the y attribute

width

Number

Alias to the x attribute