I've been needing help with this code I found to get scanlines for Paint.net.
I'm trying to make the scanlines be diagonal, along with horizontal and vertical. Does anyone have an idea how to do this?
FULL CODE:
int Amount1=5; //[2,25]Scanline Width
int Amount2=1; //[1,5]Brush Width
int Amount3=0; //[0,1]Horizontal Vertical
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.B ounds);
ColorBgra CurrentPixel;
bool Odd = false;
// Get the current brush width for grids
int w = Amount2;
bool Orientation = (Amount3 == 0);
ColorBgra PrimaryColor;
PrimaryColor.A = 255;
PrimaryColor.R = 0;
PrimaryColor.G = 0;
PrimaryColor.B = 0;
// 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 (Orientation)
{
if (((y-t) % GridSize) == 0)
Odd = true;
}
else
{
if (((x-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;
}
}
}
}