bloom

Effects

Every effect in the fx package, its fields, and whether it suits a transition, a backdrop, or feedback.

All effects are in github.com/lrstanley/bloom/fx. Each takes a progress t from 0 to 1:

  • As a transition (bloom.Transition, bloom.Present, Layer.Presence, Layer.Transition), it changes the node's own cells. t runs from 0, starting to enter, to 1, fully shown and unchanged.
  • As a backdrop or shadow (Layer.Backdrop, Layer.Shadow), it changes the frame beneath a layer. t is the strength, following the layer's transition.
  • Some take their own progress, such as a shake's or a burst's, and are applied with bloom.Transition while it runs.

Edge fields take bloom.Top, bloom.Bottom, bloom.Left, or bloom.Right (also available as fx.Top and so on). The zero value is Bottom. Seed fields pick a random pattern that stays the same for the same seed.

Entrances

EffectFieldsBrings a node in by
Fadecrossfading from what's beneath it
SlideFrom Edgemoving in from beyond an edge of its viewport
WipeFrom Edgerevealing it from one edge to the other
DissolveSeedrevealing its cells in a random order
Typewriterrevealing its cells in reading order
ScrambleSeedrandom glyphs settling into its own
DecodeSeedcolumns falling into place like digital rain
Unfoldopening from its middle row outward, like a CRT turning on
IrisAt image.Pointa circle growing from At (screen coordinates; zero is the node's center)
ShadeSeedeach cell stepping through ░ ▒ ▓ to its glyph
BlindsFrom Edge, Size int (default 3)opening slats, like window blinds
WaveFrom Edgea wobbling front sweeping across, with a bright crest
GlitchSeeda breaking-up signal that settles, with jitter and split colors

Backdrops

EffectFieldsChanges what's beneath a layer by
DimAmount float64moving colors toward the terminal's background
DesaturateAmount float64moving colors toward gray
TintColor color.Color, Amount float64moving colors toward Color
RecolorFg, Bg color.Colordrawing every cell in two colors, keeping the glyphs
SpotlightRect image.Rectangle, Amount float64 (default 0.7), Soft intdimming everything outside Rect, with a soft edge Soft cells wide

Amount runs from 0, no change, to 1, all the way. Backdrops also work as transitions; Tint on a node fades it in from a color, for example.

Feedback

These take their own progress rather than an entrance's. See Feedback effects for how to drive them.

EffectFieldsDoes
ShakeAmount int (default 2), Times int (default 4)moves the node side to side with a decaying wobble; still at 0 and 1
ShimmerColor color.Color, Width int (default 6)sweeps a highlight band across the node; t is the band's position
RollFrom stringturns digits over like an odometer, from the number in From
BurstAt image.Point, Count int (default 40), Seedthrows confetti from At; t is its age, gone at 1

Combinators

These wrap other effects.

EffectFieldsDoes
StaggerEffect, From Edge, Spread float64 (default 0.5)runs Effect on each row (From top or bottom) or column (left or right), one after another
DelayEffect, From, To float64 (To defaults to 1)runs Effect only between From and To of the progress
ReverseEffectruns Effect with 1-t
EaseEffect, Easing func(float64) float64runs Effect with eased progress, such as anim.OutBack

Your own

TypeDoes
Functurns a func(*canvas.Surface, float64) into an effect

Any type with an Apply(*canvas.Surface, float64) method is an effect. See Custom effects.

Things to know

  • Effects listed together run in order with the same t.
  • Effects that need the terminal's colors (Dim, Shimmer with no color, Wave) work best when the root has heard them: return m.ui.Init() from Init and pass messages to m.ui.Update.
  • Effects that replace glyphs (Scramble, Decode, Shade, Glitch) leave wide characters, such as emoji, alone or reveal them in one step, so they never draw half a character.
  • Ease and Func hold functions, which can't be compared, so frames using them are redrawn every time. Keep them on nodes that are animating.

Last updated on

On this page