Skip to content

arte generativa FODA #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
color: blue;
}
</style>

</head>
<body>
<h1><a href="https://github.com/unleashed-coding">Unleashed</a></h1>
Expand Down
37 changes: 37 additions & 0 deletions sqdorte/artegenerativafoda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
function setup() {
createCanvas(screen.width-100, screen.height-150);

c = createVector(width/2, height/2); // center
q = createVector(+1, +1); // quadrant
l = 100; // length
s = 5; // step
i = 0; // index
y = 1; // current iteration
z = Math.floor(Math.random()*80 + 30); // max iterations
}

function draw() {
if (y <= z) {
if (i <= l/s) {
a = createVector(c.x + q.x * i*s, c.y);
b = createVector(c.x, c.y - q.y * l + q.y * i*s);
line(a.x, a.y, b.x, b.y);
i++;
} else {
// select a new center point
m = Math.random();
n = m < 0.33 ? -1 : m < 0.66 ? 0 : 1
m = Math.random();
o = m < 0.33 ? -1 : m < 0.66 ? 0 : 1
c = createVector(c.x + n * l, c.y + o*l)
// select a new quadrant
q = createVector(
Math.random() < 0.5 ? -1 : 1,
Math.random() < 0.5 ? -1 : 1
);

i = 0;
y++;
}
}
}
4 changes: 2 additions & 2 deletions sqdorte/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jooj</title>
<title>arte generativa FODA</title>
<style> body {padding: 0; margin: 0;} </style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.min.js"></script>
<script src="jooj.js"></script>
<script src="artegenerativafoda.js"></script>
</head>
<body>
</body>
Expand Down