Package net.ixdarklord.folios.api.client
Interface FoliosReveal
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
How a page's content shows once the page is turned to: everything drawn on it (text, pictures, items, scenes,
whatever a page type draws) asks the effect how it looks at this point of the reveal, by where it is on the page.
Register one with
FoliosReveals.register(net.minecraft.resources.ResourceLocation, net.ixdarklord.folios.api.client.FoliosReveal); a book chooses it in book.json and an entry may choose its own:
"reveal": "mymod:shimmer" // an effect, for its default length
"reveal": {"effect": "folios:rise", "seconds": 0.6} // and how long it takes
"reveal": {"effect": "folios:ink", "once": true} // only the first time each spread is seen this game
"reveal": {"effect": "folios:ink", "unread": true} // only on spreads the reader hasn't been shown before
"reveal": "none" // shown at once
An effect is asked once for each thing drawn each frame while it plays, so it should be cheap: arithmetic, no
allocation beyond the FoliosReveal.Look it returns (or one of the constants).
// Each line slides in from the left, the higher ones first.
FoliosReveals.register(MyMod.id("slide"), (progress, x, y) -> {
float local = FoliosReveal.stagger(progress, y / FoliosLayout.PAGE_HEIGHT, 0.5F);
return new FoliosReveal.Look(local, -(1 - FoliosReveal.easeOut(local)) * 12, 0);
});
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordHow a thing looks: how much it shows (0 not at all, 1 fully; items and scenes, which can't fade, show once past a half), how far it is moved from its place in page pixels, a colour it is tinted towards (tint's alpha is how far: 0 not at all), and what share of its letters, if it is text, show as runes (0 none, 1 all).static final recordA reveal: an effect, how long it takes in seconds, whether it plays only the first time each spread is seen this game (once; pages of entries read in an earlier game count as seen), and whether it plays only on spreads the reader has never been shown in full (unread; kept with the player, or with the copy of a book that keeps its own, so it doesn't play again after a restart or on another computer). -
Method Summary
Modifier and TypeMethodDescriptiondefault voidaround(FoliosPainter painter, float progress, float seconds, float x, float y, float width, float height, float spreadX, float spreadY) Draws about one thing on the page just after it is drawn while the reveal plays: flames on a letter catching fire, a glow round an item.static floateaseOut(float t) Eases 0 to 1 quickly at first and gently into its end.look(float progress, float x, float y) How something drawn at (x, y) looks at this point of the reveal.static floatnoise(int seed) A steady pseudo-random number from 0 to 1 for a seed: for where sparks start, which letters flicker.default voidoverlay(FoliosPainter painter, float progress, float seconds, float pageX) Draws over a page while the reveal plays (progress under 1), after its content: fire along a burning edge, smoke, sparks, floating symbols.static floatsmooth(float t) Eases 0 to 1 gently at both ends.static floatstagger(float progress, float place, float spread) A part's own progress when parts start one after another:place(0 to 1) is where it is in the order, andspreadhow much of the reveal the starts are spread over (0 all together, nearly 1 one at a time).
-
Method Details
-
look
How something drawn at (x, y) looks at this point of the reveal.- Parameters:
progress- how far the reveal has gone, 0 as the page lands to 1 when it is done (and 1 from then on)x- where it is drawn across the open spread, in page pixels: 0 at the left page's outer edge,FoliosLayout.PAGE_WIDTHat the fold, twice that at the right page's outer edge; so an effect runs on over the foldy- where it is drawn down the page, in page pixels (0 toFoliosLayout.PAGE_HEIGHT)
-
overlay
Draws over a page while the reveal plays (progress under 1), after its content: fire along a burning edge, smoke, sparks, floating symbols. In the page's own pixels, through its painter;pageXis where the page starts across the spread (0 orFoliosLayout.PAGE_WIDTH), for drawing what runs on over the fold. Nothing by default. Each thing drawn here is drawn every frame, so a few hundred fills at most.- Parameters:
seconds- a clock for what flickers or drifts (the book's)
-
around
default void around(FoliosPainter painter, float progress, float seconds, float x, float y, float width, float height, float spreadX, float spreadY) Draws about one thing on the page just after it is drawn while the reveal plays: flames on a letter catching fire, a glow round an item.x,y,widthandheightare where it is in the painter's own pixels, for drawing;spreadXandspreadYwhere its middle is across the spread, aslook(float, float, float)is given it. Called for letters, items and pictures (not for plain fills), so keep it to a few fills, and only where it shows. Nothing by default. -
stagger
static float stagger(float progress, float place, float spread) A part's own progress when parts start one after another:place(0 to 1) is where it is in the order, andspreadhow much of the reveal the starts are spread over (0 all together, nearly 1 one at a time). -
easeOut
static float easeOut(float t) Eases 0 to 1 quickly at first and gently into its end. -
noise
static float noise(int seed) A steady pseudo-random number from 0 to 1 for a seed: for where sparks start, which letters flicker. -
smooth
static float smooth(float t) Eases 0 to 1 gently at both ends.
-