-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fractals.pde
115 lines (81 loc) · 1.51 KB
/
Fractals.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
int length_ver=150;
float angle=4.2;
float grow=190.0;
float value=1.0;
float Width = 0;
void setup()
{
size(1000, 1000);
Width = width;
}
void draw()
{
background(51);
//SorpynskyTringle();
FractalTree();
//angle+=0.0001;
//grow+=0.01;
}
public void FractalTree()
{
translate(width/2,height);
branch(length_ver,angle);
}
public void SorpynskyTringle()
{
ellipse(Width/2, height/2, grow,grow);
Circ(Width/2, height/2, grow);
}
public void Circ(int x, int y, float rad)
{
if (rad>value)
{
noFill();
stroke(255);
ellipse(x-grow, y, rad*angle,rad*angle);
ellipse(x+grow, y, rad*angle,rad*angle);
Circ(int(x-rad/2), y, rad*angle);
Circ(int(x+rad/2), y, rad*angle);
Circ(x, int(y+rad/2), rad*angle);
//Circ(x/2, y, rad*0.8);
}
}
//branch is a line that has 2 smaller lines attached
//function-->branch(me):branch(smaller);
public void branch(int l, float angle)
{
if (l>1)
{
stroke(255);
line(0, 0, 0, -l);
translate(0, -l);
pushMatrix();
rotate(PI/angle);
branch(int(l*0.75), angle);
popMatrix();
pushMatrix();
rotate(-(PI/angle));
branch(int(l*0.75), angle);
popMatrix();
//push();
//rotate((PI/angle));
//branch(int(l*0.57),angle);
//pop();
//branch((y-l)-2,x+2,y-2);
}
}
void mousePressed()
{
angle+=0.215;
//value+=0.03;
//length_ver-=2;
}
void keyPressed()
{
if(keyCode==' ')
{
PImage saver=get();
save(saver);
saveFrame("tranpiskyTriangle_###.png");
}
}