CPSparkleShader
Color sparkle shader.
This shader provides color sparkle effect for the entire camera frame. Sparkling consists of picking number of random pixels on the frame and gradually dimming and brightening their colors creating a sparkling effect. Not that unlike CPShimmerShader that produces a random color changes, this shader relies on smooth gradual dimming and brightening. Both effects are visually similar but work differently.
Attributes
- autoStart
Whether to start shader right away. Default value is
false
.- colors
Set of color to use for sparking effect. Colors will be randomly chosen for each pixel.
- durMs
Duration of the effect in milliseconds. By default, the effect will go forever.
- entireFrame
Whether apply to the entire camera frame or just the object this shader is attached to.
- onDuration
Optional callback to call when this shader finishes by exceeding the duration specified by
durMs
parameter. Default is a no-op.- ratio
Percentage of pixels to sparkle at the same time. Default value is
0.04
, i.e. 4%. For example, if the camera frame size is 100x50 characters then the default 4% ratio will result in 200 pixels sparkling at any given time.- skip
Predicate allowing to skip certain pixel from the shader. Predicate takes a pixel (with its Z-order), and X and Y-coordinate of that pixel. Note that XY-coordinates are always in relation to the entire canvas. Typically used to skip background or certain Z-index. Default predicate returns
false
for all pixels.- steps
Number of frames that it takes for entire sparkle cycle from brightening to dimming back.
- See also:
- Example:
See CPShaderExample class for the example of using shaders.
See org.cosplay.games.pong.CPPongTitleScene game scene for example of using this shader.
- Source:
- CPSparkleShader.scala
- Graph
- Supertypes