Package squidpony.squidgrid.gui.gdx
Class Radiance
java.lang.Object
squidpony.squidgrid.gui.gdx.Radiance
- All Implemented Interfaces:
Serializable
public class Radiance extends Object implements Serializable
Grouping of qualities related to glow and light emission. When a Radiance variable in some object is null, it
means that object doesn't emit light; if a Radiance variable is non-null, it will probably emit light unless the
color of light it produces is fully transparent. Light may take up one cell or extend into nearby cells, and the
radius may change over time in up to two patterns (flicker, which randomly increases and decreases lighting radius,
and/or strobe, which increases and decreases lighting radius in an orderly retract-expand-retract-expand pattern).
You can set the
This object has 6 fields, each a float:
Created by Tommy Ettinger on 6/16/2018.
flare
variable to some value between 0.0f and 1.0f to temporarily expand the minimum radius
for strobe and/or flare, useful for gameplay-dependent brightening of a Radiance.
This object has 6 fields, each a float:
- range, how far the light extends; 0f is "just this cell"
- color, the color of the light as a float; typically opaque and lighter than the glowing object's color
- flicker, the rate of random continuous change to radiance range
- strobe, the rate of non-random continuous change to radiance range
- flare, used to suddenly increase the minimum radius of lighting; expected to be changed after creation
- delay, which delays the pattern of effects like strobe so a sequence can be formed with multiple Radiance
Created by Tommy Ettinger on 6/16/2018.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description float
color
The color of light as a float; typically opaque and lighter than the glowing object's symbol.float
delay
A time delay that applies to when the strobe and flicker effects change; useful with strobe to make a strobe expand its lit radius at one point, then expand at a slightly later time at another Radiance with a delay.float
flare
A temporary increase to the minimum radiance range, meant to brighten a glow during an effect.float
flicker
The rate of random continuous change to radiance range, like the light from a campfire.float
range
How far the radiated light extends; 0f is "just this cell", anything higher can go into neighboring cells.float
strobe
The rate of non-random continuous change to radiance range, like a mechanical strobe effect. -
Constructor Summary
Constructors Constructor Description Radiance()
All-default constructor; makes a single-cell unchanging white light.Radiance(float range)
Makes an unchanging white light with the specified range in cells.Radiance(float range, float color)
Makes an unchanging light with the given color (as a packed float) and the specified range in cells.Radiance(float range, float color, float flicker)
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal.Radiance(float range, float color, float flicker, float strobe)
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal.Radiance(float range, float color, float flicker, float strobe, float delay)
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal.Radiance(float range, float color, float flicker, float strobe, float delay, float flare)
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal.Radiance(float range, com.badlogic.gdx.graphics.Color color, float flicker, float strobe)
Makes a flickering light with the given color (as a libGDX Color) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal.Radiance(Radiance other)
Copies another Radiance exactly, except for the pattern its flicker may have, if any. -
Method Summary
Modifier and Type Method Description float
currentRange()
Provides the calculated current range adjusted for flicker and strobe at the current time in milliseconds, with flicker seeded with the identity hash code of this Radiance.static Radiance
deserializeFromString(String data)
boolean
equals(Object o)
int
hashCode()
static Radiance[]
makeChain(int length, float range, float color, float strobe)
Makes a chain of Radiance objects that will pulse in a sequence, expanding from one to the next.String
serializeToString()
String
toString()
-
Field Details
-
range
How far the radiated light extends; 0f is "just this cell", anything higher can go into neighboring cells. This is permitted to be a non-integer value, which will make this extend into further cells partially. -
color
The color of light as a float; typically opaque and lighter than the glowing object's symbol. -
flicker
The rate of random continuous change to radiance range, like the light from a campfire. The random component of the change is determined by theSystem.identityHashCode(Object)
of this Radiance, which will probably make all flicker effects different when flicker is non-0. -
strobe
The rate of non-random continuous change to radiance range, like a mechanical strobe effect. This looks like a strobe light when the value is high enough, but at lower values it will smoothly pulse, which can be less distracting to players. -
delay
A time delay that applies to when the strobe and flicker effects change; useful with strobe to make a strobe expand its lit radius at one point, then expand at a slightly later time at another Radiance with a delay. The range for delay should be considered 0f to 1f, with 0f the default (no delay) and values between 0 and 1f that fraction of a full strobe delayed from that default. -
flare
A temporary increase to the minimum radiance range, meant to brighten a glow during an effect. This should be a float between 0f and 1f, with 0f meaning no change and 1f meaning always max radius.
-
-
Constructor Details
-
Radiance
public Radiance()All-default constructor; makes a single-cell unchanging white light. -
Radiance
Makes an unchanging white light with the specified range in cells.- Parameters:
range
- possibly-non-integer radius to light, in cells
-
Radiance
Makes an unchanging light with the given color (as a packed float) and the specified range in cells.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- packed float color, as produced byColor.toFloatBits()
-
Radiance
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- packed float color, as produced byColor.toFloatBits()
flicker
- the rate at which to flicker, as a non-negative float
-
Radiance
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal. Usually one of flicker or strobe is 0; if both are non-0, the radius will be smaller than normal.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- packed float color, as produced byColor.toFloatBits()
flicker
- the rate at which to flicker, as a non-negative floatstrobe
- the rate at which to strobe or pulse, as a non-negative float
-
Radiance
Makes a flickering light with the given color (as a libGDX Color) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal. Usually one of flicker or strobe is 0; if both are non-0, the radius will be smaller than normal.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- a libGDX Color object; will not be modifiedflicker
- the rate at which to flicker, as a non-negative floatstrobe
- the rate at which to strobe or pulse, as a non-negative float
-
Radiance
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal. Usually one of flicker or strobe is 0; if both are non-0, the radius will be smaller than normal. The delay parameter is usually from 0f to 1f, and is almost always 0f unless this is part of a group of related Radiance objects; it affects when strobe and flicker hit "high points" and "low points", and should usually be used with strobe.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- packed float color, as produced byColor.toFloatBits()
flicker
- the rate at which to flicker, as a non-negative floatstrobe
- the rate at which to strobe or pulse, as a non-negative floatdelay
- a delay applied to the "high points" and "low points" of strobe and flicker, from 0f to 1f
-
Radiance
Makes a flickering light with the given color (as a packed float) and the specified range in cells; the flicker parameter affects the rate at which this will randomly reduce its range and return to normal, and the strobe parameter affects the rate at which this will steadily reduce its range and return to normal. Usually one of flicker or strobe is 0; if both are non-0, the radius will be smaller than normal. The delay parameter is usually from 0f to 1f, and is almost always 0f unless this is part of a group of related Radiance objects; it affects when strobe and flicker hit "high points" and "low points", and should usually be used with strobe. This allows setting flare, where flare is used to create a sudden increase in the minimum radius for the Radiance, but flare makes the most sense to set when an event should brighten a Radiance, not in the constructor. Valid values for flare are usually between 0f and 1f.- Parameters:
range
- possibly-non-integer radius to light, in cellscolor
- packed float color, as produced byColor.toFloatBits()
flicker
- the rate at which to flicker, as a non-negative floatstrobe
- the rate at which to strobe or pulse, as a non-negative floatdelay
- a delay applied to the "high points" and "low points" of strobe and flicker, from 0f to 1fflare
- affects the minimum radius for the Radiance, from 0f to 1f with a default of 0f
-
Radiance
Copies another Radiance exactly, except for the pattern its flicker may have, if any.- Parameters:
other
- another Radiance to copy
-
-
Method Details
-
currentRange
Provides the calculated current range adjusted for flicker and strobe at the current time in milliseconds, with flicker seeded with the identity hash code of this Radiance. Higher values of flicker and strobe will increase the frequency at which the range changes but will not allow it to exceed its starting range, only to diminish temporarily. If both flicker and strobe are non-0, the range will usually be smaller than if only one was non-0, and if both are 0, this simply returns range.- Returns:
- the current range, adjusting for flicker and strobe using the current time
-
makeChain
Makes a chain of Radiance objects that will pulse in a sequence, expanding from one to the next. This chain is an array of Radiance where the order matters.- Parameters:
length
- how many Radiance objects should be in the returned arrayrange
- in cells, how far each Radiance should expand from its start at its greatest radiuscolor
- as a packed float colorstrobe
- the rate at which the chain will pulse; should be greater than 0- Returns:
- an array of Radiance objects that will pulse in sequence.
-
toString
-
equals
-
hashCode
-
serializeToString
-
deserializeFromString
-