Add Fractal tree initial commit

This commit is contained in:
Lev
2021-07-17 19:00:18 -05:00
parent a5713b51c4
commit 46dbbbc462
4 changed files with 83 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>graphicsProgramming - Coursera</title>
<script src="libraries/p5.min.js" type="text/javascript"></script>
<script src="libraries/p5.sound.min.js" type="text/javascript"></script>
<script src="sketch.js" type="text/javascript"></script>
<style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style>
</head>
<body>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,37 @@
// Code from a modified Daniel Shiffman example
// https://thecodingtrain.com/
var angle = 0;
var seed;
function setup() {
createCanvas(400, 400);
seed = random(1000);
}
////////////////////////////////////////////////
function draw() {
background(225);
angleMode(DEGREES);
randomSeed(seed);
angle = 45;
stroke(255);
translate(200, height);
branch(100, 3);
}
/////////////////////////////////////////////////
function branch(len, thickness) {
stroke(0);
strokeWeight(thickness);
line(0, 0, 0, -len);
translate(0, -len);
if (len > 4) {
push();
rotate(angle);
branch(len * 0.67, thickness*0.8);
pop();
push();
rotate(-angle);
branch(len * 0.67, thickness*0.8);
pop();
}
}