Some progress.......
// Name: Box Outlining GPU
// Submenu: test
// Author:
// Title:
// Version:
// Desc:
// Keywords:
// URL:
// Help:
// For help writing a GPU Drawing plugin: https://boltbait.com/pdn/CodeLab/help/tutorial/drawing/
#region UICode
IntSliderControl Amount2 = 35; // [15,100] Size
IntSliderControl Amount3 = 9; // [2,25] Spacing
#endregion
protected override unsafe void OnDraw(IDeviceContext deviceContext)
{
deviceContext.DrawImage(Environment.SourceImage); // preserve background
// find out where our selection is located
RectInt32 selection = Environment.Selection.RenderBounds;
// variables
int boxSize = Amount2/2;
int Spacing = Amount3+1;
int doubleSpacing = Amount3*2;
int thickness = 2;
int rndHeight, rndWidth;
int step = boxSize*7/10;
// define your brush and stroke style
ISolidColorBrush fillBrush = deviceContext.CreateSolidColorBrush(LinearColors.LightGray);
ISolidColorBrush outlineBrush = deviceContext.CreateSolidColorBrush(LinearColors.Black);
IStrokeStyle boxStrokeStyle = deviceContext.Factory.CreateStrokeStyle(StrokeStyleProperties.Default);
// setup drawing mode
deviceContext.AntialiasMode = AntialiasMode.Aliased; // or .PerPrimitive
Random rnd = new Random();
for (int y = selection.Top; y < selection.Bottom; y += step)
{
for (int x = selection.Left; x < selection.Right; x += step)
{
//if source pixel is opaque )
rndWidth = rnd.Next(Spacing, doubleSpacing);
rndHeight = rnd.Next(Spacing, doubleSpacing);
deviceContext.FillRectangle(x-rndWidth, y-rndHeight, boxSize, boxSize, fillBrush);
deviceContext.DrawRectangle(x-rndWidth, y-rndHeight, boxSize, boxSize, outlineBrush, thickness, boxStrokeStyle);
}
}
}
I haven't figured out how to poll the source pixel yet, so I'm just filling selections at the moment. Still, I think looks great!