File:Снежинка .png

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

Снежинка_.png(425 × 417 pixels, file size: 39 KB, MIME type: image/png)

Captions

Captions

fractal Koch snowflake

Summary[edit]

Description
Русский: Снежинка
English: Snowflake
Date
Source Own work
Author Владислав Молдован

Pascal src code[edit]

  • N - number of corners
  • K1 - coefficient of change of the first radius
  • K2 - coefficient of change of the second radius
  • DeltaAngle - branch angle
uses GraphABC;
const
  N = 11;
  K1 = 4;
  K2 = 0.6;
  DeltaAngle = 50;

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

procedure Star(x, y, r, angle: real);
  procedure Draw(x, y, r, angle: real);
  begin
    if r > 10 then
    begin
      var ang1 := DegToRad(angle);
      var cx := x + r * Cos(ang1);
      var cy := y + r * Sin(ang1);
      
      var mx := (x + cx) / 2;
      var my := (y + cy) / 2;
      RLine(x, y, mx, my);
      Draw(mx, my, r * K2, angle);
      Draw(mx, my, r * K2, angle + DeltaAngle);
      Draw(mx, my, r * K2, angle - DeltaAngle);
    end;
  end;

begin
  var ang1 := 360 / N;
  var ang2 := DegToRad(angle);
  var cx := x + r * Cos(ang2);
  var cy := y + r * Sin(ang2);
  
  var r2 := r * K1;
  Draw(cx, cy, r2, angle);
  
  for var i := 1 to N do
  begin
    var ang3 := DegToRad(ang1 * i + angle);
    var cx2 := x + r * Cos(ang3);
    var cy2 := y + r * Sin(ang3);
    RLine(x, y, cx2, cy2);
    RLine(cx2, cy2, cx, cy);
    cx := cx2;
    cy := cy2;
    
    Draw(cx2, cy2, r2, RadToDeg(ang3));
  end;
end;

begin
  SetWindowIsFixedSize(true);
  LockDrawing();
  
  SetPenColor(clCyan);  
  while true do
    for var i := 0 to 359 do
    begin
      ClearWindow(clBlack);
      Star(Window.Width / 2, Window.Height / 2, 30, i);
      Redraw();
    end;
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
current14:14, 1 September 2017Thumbnail for version as of 14:14, 1 September 2017425 × 417 (39 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