WaveShape class abstract
Abstract base class for defining wave shape mathematical functions.
A WaveShape defines how a wave curve is calculated at any given point. Different wave shapes produce different visual patterns, from simple sine waves to complex composite waves with harmonics and noise.
Implementations must provide the computeOffset method that calculates the wave's y-coordinate for a given x-coordinate and wave parameters.
Constructors
- WaveShape()
-
const
-
WaveShape.composite({required List<
WaveShape> waves, List<double> ? weights}) -
Creates a composite wave from multiple wave shapes
waves- List of wave shapes to combineweights- Optional weights for each wave (default: equal weight for all)constfactory - WaveShape.cosine()
-
Creates a cosine wave shape (sine wave shifted by π/2)
constfactory
- WaveShape.deepWaterGerstner({double steepness, double depth, double windSpeed})
-
Creates a deep water Gerstner wave with realistic dispersion relation
steepness- Controls the sharpness of wave crests (default: 0.4)depth- Water depth factor affecting wave behavior (default: 1.0)windSpeed- Wind speed factor for wave generation (default: 10.0)constfactory - WaveShape.gerstner({double steepness})
-
Creates a Gerstner wave with more realistic water-like motion
steepness- Controls the sharpness of wave crests (default: 0.5)constfactory -
WaveShape.harmonic({List<
double> harmonics}) -
Creates a harmonic wave combining multiple sine waves
harmonics- List of amplitude multipliers for each harmonicconstfactory -
WaveShape.multiDirectionalGerstner({double steepness, List<
double> directions, List<double> directionWeights}) -
Creates a multi-directional Gerstner wave with wave trains from different angles
steepness- Controls the sharpness of wave crests (default: 0.5)directions- List of wave direction angles in radians (default:0, π/4, -π/4)directionWeights- Amplitude weights for each direction (default:1.0, 0.6, 0.4)constfactory - WaveShape.noise({double noiseFactor, int seed})
-
Creates a noisy wave by adding random variations to a sine wave
noiseFactor- Controls noise intensity (default: 0.3)seed- Random seed for reproducible noise (default: 42)constfactory - WaveShape.sawtooth()
-
Creates a sawtooth wave shape with sharp drops
constfactory
- WaveShape.shallowGerstner({double steepness, double shoalingFactor, double bottomFriction})
-
Creates a shallow water Gerstner wave with nonlinear effects
steepness- Controls the sharpness of wave crests (default: 0.3)shoalingFactor- Controls shallow water shoaling effects (default: 1.2)bottomFriction- Controls bottom friction effects (default: 0.1)constfactory - WaveShape.sine()
-
Creates a standard sine wave shape
constfactory
- WaveShape.spiral({double spiralFactor})
-
Creates a spiral wave with increasing amplitude over distance
spiralFactor- Controls how quickly the amplitude increases (default: 0.01)constfactory - WaveShape.square()
-
Creates a square wave shape with sharp transitions
constfactory
- WaveShape.stormGerstner({double steepness, double foamFactor, double turbulence})
-
Creates a storm wave using enhanced Gerstner wave with foam and turbulence
steepness- Controls the sharpness of wave crests (default: 0.8)foamFactor- Controls foam generation on wave crests (default: 0.3)turbulence- Controls wave turbulence and irregularity (default: 0.5)constfactory - WaveShape.triangle()
-
Creates a triangular wave shape with linear segments
constfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
computeOffset(
{required double x, required double width, required double amplitude, required double frequency, required double phase, required double verticalOffset}) → Offset - Computes the wave offset at a specific horizontal position.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited