Class TwinkleEffect
Scatters points of light through the empty parts of a region, each fading up and back down on its own clock before moving somewhere else.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public sealed class TwinkleEffect : AmbientEffectBase, ITextEffect, IDisposable
Remarks
Every point picks a blank cell, a glyph and a lifetime, brightens over the first half of that lifetime and dims over the second, then vanishes and starts again elsewhere. The lifetimes are staggered at the start, so the field is already mid-cycle on the first frame rather than pulsing in unison. The result is a slow shimmer that suits a title screen or a night sky behind menu text.
Only cells that were empty when the effect started are used. Text in the region is left alone rather than twinkled over, which is what lets this run underneath a logo or a menu without touching it. A region with no empty cells produces nothing.
Each point fades between the cell's own background and Color, so a dim color gives a subtle field and a bright one gives hard sparkles. Fully faded points are indistinguishable from the background they sit on.
Cost is proportional to the number of points rather than to the size of the region: only cells holding a point are written, plus the one cell a point vacates when it moves.
Properties
Color
Gets or sets the color a point reaches at the top of its fade. Defaults to the grid's foreground.
Declaration
public Color32 Color { get; set; }
Property Value
| Type | Description |
|---|---|
| Color32 |
Remarks
Points fade between the background of the cell they sit on and this color, so the brightness of the field is set here. A color close to the background gives a shimmer that is barely there; a bright one gives sparkles that compete with the text.
This is the peak, reached only at the middle of a point's life. Points spend the rest of it climbing to that or falling away from it, so the field averages about half of whatever is set here. Picking an already dim color on the reasoning that the field should be subtle halves it again and leaves nothing visible; start from the text color and come down from there.
Density
Gets or sets how much of the region's empty space is lit at any one moment, as a fraction of its blank cells. Defaults to 0.04, a sparse field.
Declaration
public float Density { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
Expressed as a fraction rather than a count so the same setting looks the same on any region: a value that reads as a scattering on a full screen would be a snowstorm in a panel. At least one point is always placed while the region has room for one.
GlyphSet
Gets or sets the characters the points are drawn from. Characters the font cannot draw are dropped when the effect starts.
Declaration
public string GlyphSet { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
MaxLifetime
Gets or sets the longest time a point lives before it moves elsewhere, in seconds.
Declaration
public float MaxLifetime { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
MinLifetime
Gets or sets the shortest time a point lives before it moves elsewhere, in seconds.
Declaration
public float MinLifetime { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
OnAmbientRefresh()
Called when the region is captured again through Refresh().
Declaration
protected override void OnAmbientRefresh()
Overrides
OnAmbientStart()
Called when the effect starts, after the region has been captured.
Declaration
protected override void OnAmbientStart()
Overrides
OnEffectRelease()
Called when the effect is disposed. Return anything rented from the context here.
Declaration
protected override void OnEffectRelease()
Overrides
OnEffectTick(float, float)
Called once per tick to draw the effect at the given progress.
Declaration
protected override void OnEffectTick(float progress, float easedProgress)
Parameters
| Type | Name | Description |
|---|---|---|
| float | progress | Linear progress from 0 to 1. |
| float | easedProgress | Progress with the easing curve applied. |
Overrides
SetColor(Color32)
Sets the color a point reaches at the top of its fade.
Declaration
public TwinkleEffect SetColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color | The peak color. |
Returns
| Type | Description |
|---|---|
| TwinkleEffect | This effect, for chaining. |
SetDensity(float)
Sets how much of the region's empty space is lit at any one moment.
Declaration
public TwinkleEffect SetDensity(float density)
Parameters
| Type | Name | Description |
|---|---|---|
| float | density | Fraction of the blank cells holding a point, from 0 to 1. |
Returns
| Type | Description |
|---|---|
| TwinkleEffect | This effect, for chaining. |
SetGlyphSet(string)
Sets the characters the points are drawn from.
Declaration
public TwinkleEffect SetGlyphSet(string glyphSet)
Parameters
| Type | Name | Description |
|---|---|---|
| string | glyphSet | Characters to draw the points with. |
Returns
| Type | Description |
|---|---|
| TwinkleEffect | This effect, for chaining. |
SetLifetime(float, float)
Sets how long the points live before they move elsewhere.
Declaration
public TwinkleEffect SetLifetime(float minimum, float maximum)
Parameters
| Type | Name | Description |
|---|---|---|
| float | minimum | Shortest lifetime in seconds. |
| float | maximum | Longest lifetime in seconds. |
Returns
| Type | Description |
|---|---|
| TwinkleEffect | This effect, for chaining. |