I am attempting to control a 240 long line of RGB pixels (ws2812b) using an artnet to dmx controller and need to generate colour gradients down the length of the line of pixels.
What you could do is let the brush draw a line on a bitmap and extract the pixels from that, but I believe that would be unnecessarily expensive and complicated. What would be better is simply lerping between the colours you want.
This can be achieved by writing a lerp method like so:
float Lerp(float from, float to, float amount)
{
return from + amount * (to - from);
}
and using this for the R G and B values of the colors you want to lerp between. For example:
Color Lerp(Color from, Color to, float amount)
{
return Color.FromArgb(
(int)Lerp(from.R, to.R, amount),
(int)Lerp(from.G, to.G, amount),
(int)Lerp(from.B, to.B, amount));
}
I hope this helps.
~Luca