Skip to content

Commit 30c11aa

Browse files
authored
Merge pull request #6 from sqdorte/master
arte generativa FODA
2 parents 7627d91 + 70abca3 commit 30c11aa

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
color: blue;
4040
}
4141
</style>
42-
4342
</head>
4443
<body>
4544
<h1><a href="https://github.com/unleashed-coding">Unleashed</a></h1>

sqdorte/artegenerativafoda.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function setup() {
2+
createCanvas(screen.width-100, screen.height-150);
3+
4+
c = createVector(width/2, height/2); // center
5+
q = createVector(+1, +1); // quadrant
6+
l = 100; // length
7+
s = 5; // step
8+
i = 0; // index
9+
y = 1; // current iteration
10+
z = Math.floor(Math.random()*80 + 30); // max iterations
11+
}
12+
13+
function draw() {
14+
if (y <= z) {
15+
if (i <= l/s) {
16+
a = createVector(c.x + q.x * i*s, c.y);
17+
b = createVector(c.x, c.y - q.y * l + q.y * i*s);
18+
line(a.x, a.y, b.x, b.y);
19+
i++;
20+
} else {
21+
// select a new center point
22+
m = Math.random();
23+
n = m < 0.33 ? -1 : m < 0.66 ? 0 : 1
24+
m = Math.random();
25+
o = m < 0.33 ? -1 : m < 0.66 ? 0 : 1
26+
c = createVector(c.x + n * l, c.y + o*l)
27+
// select a new quadrant
28+
q = createVector(
29+
Math.random() < 0.5 ? -1 : 1,
30+
Math.random() < 0.5 ? -1 : 1
31+
);
32+
33+
i = 0;
34+
y++;
35+
}
36+
}
37+
}

sqdorte/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>jooj</title>
6+
<title>arte generativa FODA</title>
77
<style> body {padding: 0; margin: 0;} </style>
88
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
9-
<script src="jooj.js"></script>
9+
<script src="artegenerativafoda.js"></script>
1010
</head>
1111
<body>
1212
</body>

0 commit comments

Comments
 (0)