Companion object containing factory methods.
Attributes
- Companion
- class
- Source
- CPAnimation.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
CPAnimation.type
Members list
Value members
Concrete methods
Creates new filmstrip animation with given parameters.
Creates new filmstrip animation with given parameters.
filmstrip animation is a variation of time-based animation where all key frames have the same duration, like in a movie, hence the name.
Value parameters
- bounce
-
If
loop
istrue
this defines how animation will loop once it reaches the last key frame: from the beginning or bounce and going backward towards the beginning. Default value isfalse
which will force looping animation to start from the beginning. - frameMs
-
Individual frame duration in milliseconds (applied to all frames).
- id
-
Unique ID of the animation.
- imgs
-
Sequence of animation images.
- loop
-
Whether or not to loop the animation. If
false
animation will stop after the last key frame is played out. Default value istrue
.
Attributes
- See also
- Source
- CPAnimation.scala
Previews given animation.
Previews given animation.
Typically, you would use this method together with image definition. Place this call into @main
function to quickly preview the animation by running this function:
object CPCubeAniImage extends CPArrayImage(
prepSeq(13 * 8,
"""
|+------+ +------+ +------+ +------+ +------+ +-------+ +------+ +------+
||`. |`. |\ |\ | | /| /| .'| .'| / | /| | | |\ |\
|| `+--+---+ | +----+-+ +------+ +-+----+ | +---+--+' | +-+----+ | +------+ | +----+-+
|| | | | | | | | | | | | | | | | | | | | | | | | | | | |
|+---+--+ | +-+----+ | +------+ | +----+-+ | +--+---+ | +----+-+ +------+ +-+----+ |
| `. | `. | \| \| | | |/ |/ | .' | .' |/ |/ | | \| \|
| `+------+ +------+ +------+ +------+ +------+' +------+ +------+ +------+
"""),
(ch, _, _) => ch&C_WHITE
)
@main def preview(): Unit =
val ani = CPAnimation.filmStrip(
"ani",
200,
true,
false,
CPCubeAniImage.trimBg().split(13, 7)
)
CPAnimation.previewAnimation(ani, CPDim(13, 7))
sys.exit(0)
Value parameters
- ani
-
Animation to preview.
- bg
-
Background pixel. Default value is
CPPixel('.', C_GRAY2, C_GRAY1)
. - emuTerm
-
Whether to use a terminal emulation. Default value is
true
. - frameDim
-
Dimension of the keyframe.
Attributes
- See also
- Source
- CPAnimation.scala
Creates new time-based animation with given parameters.
Creates new time-based animation with given parameters.
Time-based animation is based on idea that animation is a sequence of image and duration pairs. Playing such animation simply means sequentially playing and image for its specified duration and then switching to the next one and repeating the same process.
Note that unlike discreet graphics based animation the timing tuning of the terminal ASCII-based animation can be tricky. It is often counterintuitive that faster refresh rate produces blurrier animation and the slower timing would sometime yield better result. There is also a significant difference on whether the sprite is moving vertically or horizontally on the terminal screen as well as how much it moves in relation to animation timing. There's also a perceptible difference in how sprite animation is viewed on the built-in terminal emulator and the actual native terminal such as iTerm2 or xterm. Make sure to experiment with timing of your animations!
Value parameters
- bounce
-
If
loop
istrue
this defines how animation will loop once it reaches the last key frame: from the beginning or bounce and going backward towards the beginning. Default value isfalse
which will force looping animation to start from the beginning. - frames
-
Animation images with their corresponding durations in milliseconds.
- id
-
Unique ID of the animation.
- loop
-
Whether or not to loop the animation. If
false
animation will stop after the last key frame is played out. Default value istrue
.
Attributes
- Returns
-
Newly created animation.
- See also
- Source
- CPAnimation.scala