File:Карта высот.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Карта_высот.png(637 × 478 pixels, file size: 56 KB, MIME type: image/png)

Captions

Captions

height map

Summary

[edit]
Description
Русский: Карта высот
English: height map
Date
Source Own work
Author Владислав Молдован

Pascal src code

[edit]
  • RndMax - upper bound
uses GraphABC;
const
  RndMax = 255;
  
type
  Point3D = class
    X, Y, Z: real;
    
    constructor(px, py, pz: real);
    begin
      X := px;
      Y := py;
      Z := pz;
    end;
  end;

procedure Draw(pA, pC: Point3D; bZ, dZ: real);
begin
  var pB := new Point3D(pC.X, pA.Y, bZ);
  var pD := new Point3D(pA.X, pC.Y, dZ);
  
  var cx := (pA.X + pB.X) / 2;
  var cy := (pB.Y + pC.Y) / 2;
  
  if (pB.X - pA.X) * (pC.Y - pB.Y) > 1 then
  begin
    var maxz := Max(Max(Max(pA.Z, pB.Z), pC.Z), pD.Z);
    var minz := Min(Min(Min(pA.Z, pB.Z), pC.Z), pD.Z);
    
    var randz := 0.0;
    if maxz - minz > 0 then randz := minz + Random() * (maxz - minz);
    var pCenter := new Point3D(cx, cy, randz);
    
    var p1 := new Point3D(cx, pA.Y, (pA.Z + pB.Z) / 2);
    var p2 := new Point3D(pB.X, cy, (pB.Z + pC.Z) / 2);
    var p3 := new Point3D(cx, pC.Y, (pC.Z + pD.Z) / 2);
    var p4 := new Point3D(pA.X, cy, (pD.Z + pA.Z) / 2);
    
    Draw(pA, pCenter, p1.Z, p4.Z);
    Draw(p1, p2, pB.Z, pCenter.Z);
    Draw(pCenter, pC, p2.Z, p3.Z);
    Draw(p4, p3, pCenter.Z, pD.Z);
  end
  else
  begin
    var zv := Round((pA.Z + pB.Z + pC.Z + pD.Z) / 4);
    SetBrushColor(RGB(0, zv, 255));
    FillRect(Round(pA.X), Round(pA.Y), Round(pC.X), Round(pC.Y));
  end;
end;

begin
  var W := Window.Width;
  var H := Window.Height;
  
  SetWindowIsFixedSize(true);
  
  LockDrawing();
  Draw(new Point3D(0, 0, Random(RndMax)), new Point3D(W, H, Random(RndMax)), Random(RndMax), Random(RndMax));
  Redraw();
end.

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:32, 1 September 2017Thumbnail for version as of 09:32, 1 September 2017637 × 478 (56 KB)Владислав Молдован (talk | contribs)User created page with UploadWizard

There are no pages that use this file.

File usage on other wikis

The following other wikis use this file:

Metadata