Построить фрактал "Ветка" Фрактал состоит из сочетания линий, координаты начала и конца определяются по формуле Line(x, y, Round(x + l * cos(u)), Round(y - l * sin(u))), "кустистость" ветки регулируется коэффициентом на котороый умножается переменная l в функции Draw program Vetka2; uses Graph, CRT; const min = 1; var gd, gm : Integer; procedure lineto1(x, y : Integer; l, u : real); begin Line(x, y, Round(x + l * cos(u)), Round(y - l * sin(u))); end; procedure Draw(x, y : Integer; l, u : real); begin if KeyPressed then exit; if l > min then begin lineto1(x, y, l, u); x := Round(x + l * cos(u)); y := Round(y - l * sin(u)); Draw(x, y, l*0.4, u - pi/4); Draw(x, y, l*0.4, u + pi/4); Draw(x, y, l*0.7, u); end; end; begin gd := Detect; InitGraph(gd, gm, 'c:\bp\bgi'); Draw(320, 460, 120, pi/2); ReadKey; CloseGraph; end.
Ключевые слова:
фрактал, ветка
|
|||||||