in ExampleGallery/GradientMeshExample.xaml.cs [155:193]
void AddDefaultPatch(bool tensor)
{
float sizeDim = Math.Min((float)canvasControl.Size.Width, (float)canvasControl.Size.Height);
Vector2[] pointArray = new Vector2[tensor ? 16 : 12];
int[] coonsIndices = { 0, 1, 2, 3, 11, 4, 10, 5, 9, 8, 7, 6 };
float topLeftMargin = (sizeDim / 10) + ((sizeDim / 10) * patchPoints.Count);
topLeftMargin = topLeftMargin % sizeDim;
float spacing = sizeDim / 10.0f;
int count = 0;
for (int y = 0; y < 4; y++)
{
for (int x = 0; x < 4; x++)
{
int index = 0;
if (tensor)
{
index = count;
}
else
{
int coordIndex = (y * 4 + x);
if (coordIndex == 5 || coordIndex == 6 || coordIndex == 9 || coordIndex == 10) continue;
index = coonsIndices[count];
}
pointArray[index] = new Vector2(topLeftMargin + (x * spacing), topLeftMargin + (y * spacing));
count++;
}
}
patchPoints.Add(pointArray);
gradientMesh = null;
canvasControl.Invalidate();
}