# Raising Highmaps (drafts)

Hello all again! Today will be a short post, raising the Diamond Square algorithm developed in prior post using just one function.

We are not going to control, this time, all features, just draft it, due the lot of possibilities that got projection, as in general as in computer science: just will apply a reduction to highmap Z-Axis to show projection, and as well add a negative offset depending on y parameter at X-Axis (i), so adding some isometric perspective. All factors are on-eye calculated: for example, we consider zero Z-Axis value at 3/4 of destination bitmap height, but of course it can be any valor about. As well, we’re applying a 2/3 reduction of our point height, only to normalize final picture.

We apply simply shadow checking out just-left pixel high, and dark our one depending on.

``` private const int _RENDERWIDTH = 1000;
private const int _RENDERHEIGHT = 550;

// raise map and draw result to a bitmap
private void RaiseToBitmap(Color[] P,int[,] W, Bitmap B)
{
int x,y; // coordinates of work array
int i,j; // projected coordinates
Color c; // color to paint

for (x=0;x<_MAXINDEX+1;x++)
for (y=0;y<_MAXINDEX+1;y++)
{
try
{
i = _RENDERWIDTH/2 - y + x;    // begin from the middle of the bitmap.
// We will offset negatively as we run highmap down (y increases) so generates some isometric
// perspective

j = 3*_RENDERHEIGHT/4 - 2*W[x,y]/3 + y/3;    // We inverse y from high map and apply a factor to it.

if (i > 1 && i < _RENDERWIDTH - 1&& j > 0 && j < _RENDERHEIGHT) // range check
{
c = P[W[x,y]];    // gets color from high map

if (W[x-1,y] > W[x,y]) // if left point is higher...
c = Color.FromArgb(0xff,c.R/3, c.G/3, c.B/3); // ...current will be at it's shadow

for(int k=j+20;k>j;k--) // lets draw it
B.SetPixel(i,k,c);

if (W[x,y] < 220 && x%4 == 0) // sea level
B.SetPixel(i,3*_RENDERHEIGHT/4 + y/3-2*220/3,P[W[x,y]]);
}
}
catch(Exception){}
}
} ```

Just that! It will generate pictures as :

Hope you enjoyed! Next time we will raytrace highmap to generate a real point-of-view scene.

As always here you got working code (please as always as well consider the free server performance…) (NOTE: from 20190924, with server changes, ASPX/.NET code will not be kept)

Best regards!