CPFadeInShader
Fade in shader.
This shader can be used for 'fade in' effect for the entire camera frame or the individual scene object it is attached to. If used for entire camera frame effect it can be attached to an off-screen sprite.
Value parameters
- autoStart
-
Whether to start shader right away. Default value is
true
. - balance
-
A function that produces value in [0, 1] range that is used in color mixture. Value
0
means that the color will be 100% background, value1
means that the color will be 100% the actual pixel color, value0.5
means that the color will be a 50% mix between the background and the actual pixel color. The function takes two parameters: first is a current frame number since the start of the effect, and the second parameter is the last frame number of the effect. First parameter is always less then the second one. By default, the the(a, b) => a.toFloat / b
function is used that gives gradual color transition through the frames range. Another popular function to use here is a sigmoid function:(a, b) => sigmoid.value(a - b / 2).toFloat()
that gives a different visual effect. - bgPx
-
Background pixel to fade in from. Background pixel don't participate in shader effect.
- durMs
-
Duration of the fade in effect in milliseconds. It can be changed later.
- entireFrame
-
Whether apply this shader to the entire camera frame or just the object this shader is attached to.
- onFinish
-
Optional callback to call when this shader finishes. Default is a no-op.
- 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.
Attributes
- See also
- Example
-
See CPShaderExample class for the example of using shaders.
- Source
- CPFadeInShader.scala
- Graph
-
- Supertypes