File:Кольцо деревьев.png

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

Кольцо_деревьев.png(597 × 597 pixels, file size: 126 KB, MIME type: image/png)

Captions

Captions

tree ring

Summary

[edit]
Description
Русский: Кольцо деревьев
English: tree ring
Date
Source Own work
Author Владислав Молдован

Pascal src code

[edit]
uses GraphABC;
const
  K1 = 0.99;
  K2 = 0.5;
  K3 = 0.45;
  IncAngle = 15;
  Rotation = 45;
  R1 = 130;
  R2 = 160;
  Iterations = 10;

procedure RLine(x, y, x1, y1: real):=Line(Round(x), Round(y), Round(x1), Round(y1));

procedure Draw(x, y, r, ang: real; toRight: boolean);
begin
  var ang1 := DegToRad(ang);
  
  var cx := x + r * Cos(ang1);
  var cy := y + r * Sin(ang1);
  
  RLine(x, y, cx, cy);
  
  if r > 1 then
    if toRight then
      Draw(cx, cy, r * K1, ang + IncAngle, toRight)
    else
      Draw(cx, cy, r * K1, ang - IncAngle, toRight);
end;

procedure Draw(x, y, r, ang: real);
begin
  Draw(x, y, r, ang, true);
  Draw(x, y, r, ang, false);
end;

procedure DrawTree(x, y, r, ang: real; iterations: integer);
begin
  var ang1 := ang;
  ang := DegToRad(ang);
  
  var cx := x + r * Cos(ang);
  var cy := y + r * Sin(ang);
  
  var mx := (x + cx) / 2;
  var my := (y + cy) / 2;
  
  RLine(x, y, cx, cy);
  
  if r < 30 then
    Draw(mx, my, r * 0.069, ang1);
  
  if iterations > 0 then
  begin
    Dec(iterations);
    var r2 := r * K2;
    DrawTree(cx, cy, r * K3, ang1, iterations);
    DrawTree(mx, my, r2, ang1 + Rotation, iterations);
    DrawTree(mx, my, r2, ang1 - Rotation, iterations);
  end;
end;

begin
  SetWindowSize(600, 600);
  SetWindowIsFixedSize(true);
  ClearWindow(clBlack);
  
  var W := Window.Width;
  var H := Window.Height;
  
  SetPenColor(clPink);
  
  LockDrawing();
  
  var W2 := W / 2;
  var H2 := H / 2;
  DrawTree(0, 0, R2, 45, Iterations);
  DrawTree(W2, 0, R1, 90, Iterations);
  DrawTree(W, 0, R2, 135, Iterations);
  DrawTree(W, H2, R1, 180, Iterations);
  DrawTree(W, H, R2, -135, Iterations);
  DrawTree(W2, H, R1, -90, Iterations);
  DrawTree(0, H, R2, -45, Iterations);
  DrawTree(0, H2, R1, 0, Iterations);
  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 2017597 × 597 (126 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