PathParticle Class
An particle that follows a path defined by an algebraic expression, e.g. "sin(x)" or "5x + 3". To use this class, the particle config must have a "path" string in the "extraData" parameter. This string should have "x" in it to represent movement (from the speed settings of the particle). It may have numbers, parentheses, the four basic operations, and the following Math functions or properties (without the preceding "Math."): "pow", "sqrt", "abs", "floor", "round", "ceil", "E", "PI", "sin", "cos", "tan", "asin", "acos", "atan", "atan2", "log". The overall movement of the particle and the expression value become x and y positions for the particle, respectively. The final position is rotated by the spawn rotation/angle of the particle.
Some example paths:
"sin(x/10) * 20" // A sine wave path.
"cos(x/100) * 30" // Particles curve counterclockwise (for medium speed/low lifetime particles)
"pow(x/10, 2) / 2" // Particles curve clockwise (remember, +y is down).
Constructor
Item Index
Methods
- combineRGBComponents static
- destroy
- generateEase static
- getBlendMode static
- hexToRGB static
- init
- length static
- normalize static
- rotatePoint static
- scaleBy static
Properties
Methods
combineRGBComponents
-
r
-
g
-
b
Combines separate color components (0-255) into a single uint color.
Parameters:
-
r
IntThe red value of the color
-
g
IntThe green value of the color
-
b
IntThe blue value of the color
Returns:
The color in the form of 0xRRGGBB
destroy
()
Destroys the particle, removing references and preventing future use.
generateEase
-
segments
Generates a custom ease function, based on the GreenSock custom ease, as demonstrated by the related tool at http://www.greensock.com/customease/.
Parameters:
-
segments
ArrayAn array of segments, as created by http://www.greensock.com/customease/.
Returns:
A function that calculates the percentage of change at a given point in time (0-1 inclusive).
getBlendMode
-
name
Gets a blend mode, ensuring that it is valid.
Parameters:
-
name
StringThe name of the blend mode to get.
Returns:
The blend mode as specified in the PIXI.blendModes enumeration.
hexToRGB
-
color
-
output
Converts a hex string from "#AARRGGBB", "#RRGGBB", "0xAARRGGBB", "0xRRGGBB", "AARRGGBB", or "RRGGBB" to an array of ints of 0-255 or Numbers from 0-1, as [r, g, b, (a)].
Parameters:
-
color
StringThe input color string.
-
output
ArrayAn array to put the output in. If omitted, a new array is created.
Returns:
The array of numeric color values.
init
()
Initializes the particle for use, based on the properties that have to have been set already on the particle.
length
-
point
Returns the length (or magnitude) of this point.
Parameters:
-
point
pixi.geom.PointThe point to measure length
Returns:
The length of this point.
normalize
-
point
Reduces the point to a length of 1.
Parameters:
-
point
pixi.geom.PointThe point to normalize
rotatePoint
-
angle
-
p
Rotates a point by a given angle.
Parameters:
-
angle
FloatThe angle to rotate by in degrees
-
p
pixi.geom.PointThe point to rotate around 0,0.
scaleBy
-
point
-
value
Multiplies the x and y values of this point by a value.
Parameters:
-
point
pixi.geom.PointThe point to scaleBy
-
value
FloatThe value to scale by.
Properties
initialPosition
pixi.geom.Point
The initial position of the particle, as all path movement is added to that.
initialRotation
Float
The initial rotation in degrees of the particle, because the direction of the path is based on that.
movement
Float
Total single directional movement, due to speed.
path
Float->Float
The function representing the path the particle should take.