Function linearSchedule
Creates a fixed-size linear schedule including both endpoints.
T[N] linearSchedule(ulong N, T)(
const T start,
const T end
) pure nothrow @nogc @safe
if ((is(T == float) || is(T == double)) && (N >= 2));
Use this for compile-time-sized lightness, chroma, or other scalar schedules.
The first and last elements are exactly start and end. Ascending,
descending, and constant schedules are supported. Values are not restricted
to a display interval such as [0, 1].
N must be at least 2. start and end must be finite; NaN and infinity
are outside this generated-schedule contract.
Parameters
| Name | Description |
|---|---|
| start | First schedule value. |
| end | Last schedule value. |
Returns
A fixed-size inclusive schedule of N values.
Preconditions
start and end are finite. This is a programmer precondition, not
a recoverable validation channel.
Allocation
Does not allocate.
Complexity
O(N).
Example
enum values = linearSchedule!5(0.0, 1.0);
static assert(values[0] == 0.0);
static assert(values[1] == 0.25);
static assert(values[2] == 0.50);
static assert(values[3] == 0.75);
static assert(values[4] == 1.0);
Example
const double start = 0.20;
const double end = 0.80;
const values = linearSchedule!3(start, end);
assert(values[0] == start);
assert(values[1] == 0.50);
assert(values[2] == end);