CPRandomFadeInShader

org.cosplay.prefabs.shaders.CPRandomFadeInShader
class CPRandomFadeInShader(entireFrame: Boolean, durMs: Long, bgPx: CPPixel, onFinish: CPSceneObjectContext => Unit, keyFrame: Int, autoStart: Boolean, skipSpaces: Boolean, skip: (CPZPixel, Int, Int) => Boolean, balance: (Int, Int) => Float) extends CPDurationShader

Fade in shader that uses random characters during fade in.

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, value 1 means that the color will be 100% the actual pixel color, value 0.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 to the entire camera frame or just the object this shader is attached to.

keyFrame

nth-frame to render the effect. For example, if key frame is 3 than the effect will change on each 3rd frame and remain the same on all subsequent frames until next key frame is reached.

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.

skipSpaces

Whether or not to skip space characters from the shader effect. Default value is false.

Attributes

See also
Example

See CPShaderExample class for the example of using shaders.

See org.cosplay.examples.image.CPImageFormatsExample example that uses this shader.

Source
CPRandomFadeInShader.scala
Graph
Supertypes
trait CPShader
trait CPAsset
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def isActive: Boolean

Tests whether this shader is in progress.

Tests whether this shader is in progress.

Attributes

Source
CPRandomFadeInShader.scala
override def render(ctx: CPSceneObjectContext, objRect: CPRect, inCamera: Boolean): Unit

Called on each frame pass on scene object that has this shaders attached to it. This callback is called regardless of whether or not the scene object is visible or in camera frame.

Called on each frame pass on scene object that has this shaders attached to it. This callback is called regardless of whether or not the scene object is visible or in camera frame.

Attributes

Definition Classes
Source
CPRandomFadeInShader.scala
def setDuration(durMs: Long): Unit

Sets the duration in millisecond for this shader effect.

Sets the duration in millisecond for this shader effect.

Value parameters

durMs

Duration of the fade in effect in milliseconds.

Attributes

Source
CPRandomFadeInShader.scala
def setOnFinish(onFinish: CPSceneObjectContext => Unit): Unit

Set the callback to call when shader effect is finished.

Set the callback to call when shader effect is finished.

Value parameters

onFinish

Override for the callback to call when shader effect is finished.

Attributes

Source
CPRandomFadeInShader.scala
def start(onFinish: CPSceneObjectContext => Unit): Unit

Resets this shaders to its initial state starting its effect on the next frame.

Resets this shaders to its initial state starting its effect on the next frame.

Value parameters

onFinish

Optional override for the callback to call when shader effect is finished. If not provided, the default value is the callback supplied at the creation of this shader.

Attributes

Source
CPRandomFadeInShader.scala

Inherited methods

protected def checkBgPixel(bgPx: CPPixel): Unit

Attributes

Inherited from:
CPDurationShader
Source
CPDurationShader.scala
protected def checkDuration(durMs: Long): Unit

Attributes

Inherited from:
CPDurationShader
Source
CPDurationShader.scala

Inherited fields

override val getOrigin: String

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Gets the origin of this asset. Typically, this should be a URL, file name or class name for in-code assets like array images, animations or system font.

Attributes

Inherited from:
CPShader
Source
CPShader.scala