Fills output_samples with a gradient through the keys: sample i of n is at t = i / (n - 1), so the first sample is at 0 and the last at 1. sorted must be sorted by t ascending. Nothing is written when there are no samples or no keys; a single sample gets the first key's color unchanged; an unsupported color space prints a message to standard error and writes nothing.
The temporary colors are allocated with context.allocator and freed before returning; the caller owns output_samples.
#import "Math";
a := Color_Keyframe.{ .{ 1, 0, 0, 1 }, 0 };
b := Color_Keyframe.{ .{ 0, 0, 1, 0 }, 1 };
keys: [2] *Color_Keyframe = .[*a, *b];
samples: [3] Vector4;
generate_color_samples(keys, .{ .HSV, .LINEAR, false }, samples);
assert(samples[0] == xyzw(1, 0, 0, 1)); // the key colors
assert(abs(samples[1].w - 0.5) < 0.0001); // alpha blends linearly
assert(samples[2].z > 0.99 && samples[2].w == 0);generate_color_samples :: (
sorted: [] *$T/Color_Keyframe,
interp: Interpolation,
output_samples: [] Vector4
)
Parameters
- sorted: [] *$T/Color_Keyframe
- interp: Interpolation
- output_samples: [] Vector4