PIXI.ObservablePoint

class ObservablePoint implements IPoint

The ObservablePoint object represents a location in a two-dimensional coordinate system, where x represents the position on the horizontal axis and y represents the position on the vertical axis.

An ObservablePoint is a point that triggers a callback when the point's position is changed.

Constructor


new PIXI.ObservablePoint(cb: (this: T) => any, scope: T, x: number, y: number) → {}

Creates a new ObservablePoint

Parameters:
Name Type Attributes Default Description
cb (this: T) => any

callback function triggered when x and/or y are changed

scope T

owner of callback

x number

<optional>

0

position of the point on the x axis

y number

<optional>

0

position of the point on the y axis

Summary


Properties from ObservablePoint

(this: T) => any
cb

The callback function triggered when x and/or y are changed

any
scope

The owner of the callback

number
x

Position of the observable point on the x axis.

number
y

Position of the observable point on the y axis.

Methods from ObservablePoint

IPointData
add(other: IPointData, outPoint: IPointData)

Adds other to this point and outputs into outPoint or a new Point.

PIXI.ObservablePoint
clone(cb, scope)
this
copyFrom(p: IPointData)
T
copyTo(p: T)
number
cross(other: IPointData)
number
dot(other: IPointData)
boolean
equals(p: IPointData)
number
magnitude()

Computes the magnitude of this point (Euclidean distance from 0, 0).

number
magnitudeSquared()
IPointData
multiply(other: IPointData, outPoint: IPointData)

Multiplies component-wise other and this points and outputs into outPoint or a new Point.

IPointData
multiplyScalar(scalar: number, outPoint: IPointData)

Multiplies each component of this point with the number scalar and outputs into outPoint or a new Point.

IPointData
normalize(outPoint: IPointData)

Computes a normalized version of this point.

IPointData
project(onto: IPointData, outPoint: IPointData)

Computes vector projection of this on onto.

IPointData
reflect(normal: IPointData, outPoint: IPointData)
this
set(x: number, y: number)
IPointData
subtract(other: IPointData, outPoint: IPointData)

Subtracts other from this point and outputs into outPoint or a new Point.

Public Properties


cb ObservablePoint.ts:15
cb: (this: T) => any

The callback function triggered when x and/or y are changed

scope ObservablePoint.ts:18
scope: any

The owner of the callback

x ObservablePoint.ts:119
x: number

Position of the observable point on the x axis.

y ObservablePoint.ts:134
y: number

Position of the observable point on the y axis.

Public Methods


add pointExtras.ts:16
add(other: IPointData, outPoint: IPointData) → {IPointData}

Adds other to this point and outputs into outPoint or a new Point.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
other IPointData

The point to add to this.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The outPoint reference or a new Point, with the result of the addition.

clone ObservablePoint.ts:40
clone(cb, scope) → {PIXI.ObservablePoint}

Creates a clone of this point. The callback and scope params can be overridden otherwise they will default to the clone object's values.

Parameters:
Name Type Description
cb

The callback function triggered when x and/or y are changed

scope

The owner of the callback

Returns:
Type Description
PIXI.ObservablePoint

a copy of this observable point

copyFrom ObservablePoint.ts:73
copyFrom(p: IPointData) → {this}

Copies x and y from the given point (p)

Parameters:
Name Type Description
p IPointData

The point to copy from. Can be any of type that is or extends IPointData

Returns:
Type Description
this

The observable point instance itself

copyTo ObservablePoint.ts:90
copyTo(p: T) → {T}

Copies this point's x and y into that of the given point (p)

Parameters:
Name Type Description
p T

The point to copy to. Can be any of type that is or extends IPointData

Returns:
Type Description
T

The point (p) with values updated

cross pointExtras.ts:181
cross(other: IPointData) → {number}

Computes the cross product of other with this point. Given two linearly independent R3 vectors a and b, the cross product, a × b (read "a cross b"), is a vector that is perpendicular to both a and b, and thus normal to the plane containing them. While cross product only exists on 3D space, we can assume the z component of 2D to be zero and the result becomes a vector that will only have magnitude on the z axis.

This function returns the z component of the cross product of the two points.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Description
other IPointData

The other point to calculate the cross product with this.

Returns:
Type Description
number

The z component of the result of the cross product.

dot pointExtras.ts:151
dot(other: IPointData) → {number}

Computes the dot product of other with this point. The dot product is the sum of the products of the corresponding components of two vectors.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Description
other IPointData

The other point to calculate the dot product with this.

Returns:
Type Description
number

The result of the dot product. This is an scalar value.

equals ObservablePoint.ts:102
equals(p: IPointData) → {boolean}

Accepts another point (p) and returns true if the given point is equal to this point

Parameters:
Name Type Description
p IPointData

The point to check

Returns:
Type Description
boolean

Returns true if both x and y are equal

magnitude pointExtras.ts:258
magnitude() → {number}

Computes the magnitude of this point (Euclidean distance from 0, 0).

Defined as the square root of the sum of the squares of each component.

Note: Only available with @pixi/math-extras.

Returns:
Type Description
number

The magnitude (length) of the vector.

magnitudeSquared pointExtras.ts:285
magnitudeSquared() → {number}

Computes the square magnitude of this point. If you are comparing the lengths of vectors, you should compare the length squared instead as it is slightly more efficient to calculate.

Defined as the sum of the squares of each component.

Note: Only available with @pixi/math-extras.

Returns:
Type Description
number

The magnitude squared (length squared) of the vector.

multiply pointExtras.ts:84
multiply(other: IPointData, outPoint: IPointData) → {IPointData}

Multiplies component-wise other and this points and outputs into outPoint or a new Point.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
other IPointData

The point to multiply with this.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The outPoint reference or a new Point, with the component-wise multiplication.

multiplyScalar pointExtras.ts:118
multiplyScalar(scalar: number, outPoint: IPointData) → {IPointData}

Multiplies each component of this point with the number scalar and outputs into outPoint or a new Point.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
scalar number

The number to multiply both components of this.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The outPoint reference or a new Point, with the multiplication.

normalize pointExtras.ts:222
normalize(outPoint: IPointData) → {IPointData}

Computes a normalized version of this point.

A normalized vector is a vector of magnitude (length) 1

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The normalized point.

project pointExtras.ts:317
project(onto: IPointData, outPoint: IPointData) → {IPointData}

Computes vector projection of this on onto.

Imagine a light source, parallel to onto, above this. The light would cast rays perpendicular to onto. this.project(onto) is the shadow cast by this on the line defined by onto .

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
onto IPointData

A non zero vector describing a line on which to project this.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The this on onto projection.

reflect pointExtras.ts:363
reflect(normal: IPointData, outPoint: IPointData) → {IPointData}

Reflects this vector off of a plane orthogonal to normal. normal is not normalized during this process. Consider normalizing your normal before use.

Imagine a light source bouncing onto a mirror. this vector is the light and normal is a vector perpendicular to the mirror. this.reflect(normal) is the reflection of this on that mirror.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
normal IPointData

The normal vector of your reflecting plane.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The reflection of this on your reflecting plane.

set ObservablePoint.ts:54
set(x: number, y: number) → {this}

Sets the point to a new x and y position. If y is omitted, both x and y will be set to x.

Parameters:
Name Type Attributes Default Description
x number

<optional>

0

position of the point on the x axis

y number

<optional>

x

position of the point on the y axis

Returns:
Type Description
this

The observable point instance itself

subtract pointExtras.ts:50
subtract(other: IPointData, outPoint: IPointData) → {IPointData}

Subtracts other from this point and outputs into outPoint or a new Point.

Note: Only available with @pixi/math-extras.

Parameters:
Name Type Attributes Description
other IPointData

The point to subtract to this.

outPoint IPointData

<optional>

A Point-like object in which to store the value, optional (otherwise will create a new Point).

Returns:
Type Description
IPointData

The outPoint reference or a new Point, with the result of the subtraction.


Powered by webdoc!