package transition
import "git.teletypegames.org/engines/inkwell/inkbase/transition"
Package transition holds the Transition contract and the fade.
A Transition is how one picture gives way to another, in two halves: the old picture is covered, the change lands on the frame it is fully hidden, and the new picture is uncovered. Seconds is the length of one half; Draw paints the cover over the frame for a cover value that runs from 0 to 1 while the old picture goes and back to 0 while the new one comes.
Fade covers with black and FadeTo with any colour. A wipe or an iris is another implementation of the same two methods.
A Stage names its own transition (see the stage package: Stage.Transition; nil is a cut), and the host runs it when the Stage gives way. The root inkwell package re-exports Transition, Fade and FadeTo; in an inkwell game a scene change also uses a quarter-second fade. At the midpoint of a scene change the old scene's OnLeave is queued, the scene changes, the visit is counted, the actors are placed, the new scene's music starts and its OnEnter is queued. Input is frozen while the old picture is going. The opening scene is entered without a transition, so the opening script runs at once.
Index
Types
type Transition
type Transition interface { // Seconds is how long one half takes: covering the old picture, and // again uncovering the new one. Seconds() float64 // Draw paints the cover over the frame. cover runs 0->1 while the old // picture goes and 1->0 while the new one comes, so 0 shows the frame // as it is and 1 hides it completely. Draw(dst *ebiten.Image, width, height int, cover float64) }
Transition is how one picture gives way to another: a scene to the next scene, a Stage to the next Stage. It runs in two halves — the old picture is covered, the swap happens at the moment it is fully hidden, and the new picture is uncovered — so whatever a Transition draws, the player never sees the frame the swap lands on.
A Transition is a value a Stage carries (Stage.Transition), and nil is a cut. Fade is the one the engine ships; a wipe or an iris is another implementation of the same two methods.
func Fade
func Fade(seconds float64) Transition
Fade is a Transition through black: the old picture darkens over the given seconds, the swap lands on the black frame, and the new picture brightens over the same span. FadeTo is the same through another colour.
func FadeTo
func FadeTo(seconds float64, to color.Color) Transition
FadeTo is Fade through the given colour — white for a flashbulb, the theme's paper for a page turn.