
But my use for it was to do something like this.


Right now it just creates the rainbow as you see it here with the colors stretching vertically down the page. It works for selections as well, but only rectangular ones. It still creates something with weird shaped selections, but it is all screwed up and I cant seem to wrap my hands around how to program around it. Also, if I had more programming experience I would have liked to have set this up like a gradient tool, but at least for now it just does the rainbow.
I have set up three selection bars for Red, Green and Blue starting colors. You can create different rainbow effects by playing with the starting colors, but the default settings will give you your standard rainbow (though for some reason the size of the image can affect how far down the color scale it gets. For example on an 800x600 image it seems to stop at light blue, but for a smaller images reaches purple and even sometimes makes it back to red - which was the intent when programming it).
Here is the code in case anyone is interested.
int Amount1=255; //[0,255]Red Start
int Amount2=0; //[0,255]Green Start
int Amount3=0; //[0,255]Blue Start
void Render(Surface dst, Surface src, Rectangle rect)
{
PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
// Delete any of these lines you don't need
Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
long CenterX = (long)(((selection.Right - selection.Left) / 2)+selection.Left);
long CenterY = (long)(((selection.Bottom - selection.Top) / 2)+selection.Top);
ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
ColorBgra SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
int BrushWidth = (int)EnvironmentParameters.BrushWidth;
int l = 1;
int p = 1530 / rect.Right;
int r = Amount1;
int g = Amount2;
int b = Amount3;
ColorBgra CurrentPixel;
for(int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{
if (selectionRegion.IsVisible(x, y))
{
CurrentPixel = src[x,y];
// TODO: Add pixel processing code here
if (x == rect.Left)
{
r = Amount1;
g = Amount2;
b = Amount3;
}
switch(l)
{
case 1:
g = g + p;
if (g > 255)
{
g = 255;
l = 2;
}
break;
case 2:
r = r - p;
if (r < 0)
{
r = 0;
l = 3;
}
break;
case 3:
b = b + p;
if (b > 255)
{
b = 255;
l = 4;
}
break;
case 4:
g = g - p;
if (g < 0)
{
g = 0;
l = 5;
}
break;
case 5:
r = r + p;
if (r > 255)
{
r = 255;
l = 6;
}
break;
case 6:
b = b - p;
if (b < 0)
{
b = 0;
l = 1;
}
break;
}
// Access RGBA values this way, for example:
CurrentPixel.R = (byte)r;
CurrentPixel.G = (byte)g;
CurrentPixel.B = (byte)b;
// CurrentPixel.A = (byte)PrimaryColor.A;
dst[x,y] = CurrentPixel;
}
}
}
}
Thanks to Miguel for showing me the 'switch' routine to use (which apparently runs faster than a bunch of if statements). I incorporated it into this and remembered to add an icon this time.
Let me know what you think. here is the link to the plugin http://Spongey437.go...om/rainbow3.dll




















