tunedude wrote:
I just created a interlace plugin, that adds stripes of configurable width and "color" (primary/secondary/transparent) to the image.
Why not just make a slight change to the Grid plugin that I already wrote?
Like this:
Code:
int Amount1=5; //[2,25]Scanline Width
int Amount2=0; //[0,1]Primary Color Secondary Color
int Amount3=1; //[1,5]Brush Width
void Render(Surface dst, Surface src, Rectangle rect)
{
// User Interface elements
int GridSize = Amount1;
bool SwapColors = (Amount2 == 1);
// Other variables
PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
ColorBgra CurrentPixel;
ColorBgra PrimaryColor;
ColorBgra SecondaryColor;
bool Odd = false;
// Get the current brush width for grids
int w = Amount3;
// Grab the primary and secondary colors (swapping if specified in the UI)
if (SwapColors) {
PrimaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
SecondaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
} else {
PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;
}
// Loop through all the pixels
for(int y = rect.Top; y < rect.Bottom; y++)
{
for (int x = rect.Left; x < rect.Right; x++)
{
// Only work with a pixel if it is selected
// (this handles convex & concave selections)
if (selectionRegion.IsVisible(x, y))
{
// Get the source pixel
CurrentPixel = src[x,y];
Odd = false;
for (int t=0; t<w; t++)
{
if (((y-t) % GridSize) == 0)
Odd = true;
}
if ( Odd )
{
CurrentPixel.R = (byte)PrimaryColor.R;
CurrentPixel.G = (byte)PrimaryColor.G;
CurrentPixel.B = (byte)PrimaryColor.B;
CurrentPixel.A = (byte)PrimaryColor.A;
}
// Save the (modified?) pixel
dst[x,y] = CurrentPixel;
}
}
}
}
And, no preview issues.
