static void Diamond(Context ctx, IntPoint2 middle, int radius) { double v1, v2, v3, v4; IntPoint2 p1, p2, p3, p4; p1 = middle.Offset(0, -radius); v1 = GetGridValue(ctx, p1); p2 = middle.Offset(-radius, 0); v2 = GetGridValue(ctx, p2); p3 = middle.Offset(0, radius); v3 = GetGridValue(ctx, p3); p4 = middle.Offset(radius, 0); v4 = GetGridValue(ctx, p4); var avg = (v1 + v2 + v3 + v4) / 4; var val = avg + GetRandom(ctx, ctx.Range); ctx.Grid[middle] = val; if (val < ctx.Min) ctx.Min = val; if (val > ctx.Max) ctx.Max = val; }
static void Rectangle(Context ctx, IntPoint2 middle, int radius) { var grid = ctx.Grid; double v1, v2, v3, v4; IntPoint2 p1, p2, p3, p4; p1 = middle.Offset(radius, radius); v1 = grid[p1]; p2 = middle.Offset(-radius, radius); v2 = grid[p2]; p3 = middle.Offset(radius, -radius); v3 = grid[p3]; p4 = middle.Offset(-radius, -radius); v4 = grid[p4]; var avg = (v1 + v2 + v3 + v4) / 4; var val = avg + GetRandom(ctx, ctx.Range); grid[middle] = val; if (val < ctx.Min) ctx.Min = val; if (val > ctx.Max) ctx.Max = val; }