static void HeightMap(Context ctx)
{
var grid = ctx.Grid;
for (int pass = 0; pass < MyMath.Log2(grid.Width); ++pass)
{
var parts = MyMath.Pow2(pass);
var size = (grid.Width - 1) / parts;
int half = size / 2;
Debug.Assert(half != 0);
for (int y = half; y < grid.Height; y += size)
{
for (int x = half; x < grid.Width; x += size)
{
var p = new IntVector2(x, y);
Rectangle(ctx, p, half);
}
}
bool odd = true;
for (int y = 0; y < grid.Height; y += half)
{
for (int x = odd ? half : 0; x < grid.Width; x += size)
{
var p = new IntVector2(x, y);
Diamond(ctx, p, half);
}
odd = !odd;
}
ctx.Range *= Math.Pow(2, -ctx.H);
}
}