“tree_001” by Cătălin George Feștilă
https://openprocessing.org/sketch/1134343
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
mouse
CC Attribution ShareAlike
tree_001
George Feștilă
xxxxxxxxxx
/*--based on https://openprocessing.org/sketch/396851--*/
var nbranchs = 73;
function setup() {
createCanvas(640, 400);
background(0, 0, 128);
noFill();
stroke(128);
noLoop();
}
function draw() {
tree(100, 200, 150, 350);
}
function mousePressed() {
background(0, 0, 128);
redraw();
}
function branch(x, y, dx, dy) {
var sign = random(dx+1.0)/(abs(dx)+5.0);
for (var i = 0; i <= x; i += 3) {
var idx = i/x;
var xi = bezierPoint(x, x + dx/2, x + dx, x + dx, idx);
var yi = bezierPoint(y, y, y + dy, y + dy, idx);
line(xi, yi, xi + sign*random(8), yi + random(18));
}
}
function tree(left, right, top, bottom) {
for (var idx = 0; idx < nbranchs; idx += 1) {
// choose a random y position
var y = random(bottom, top);
// choose a random x position inside of a triangle
var dx = map(y, bottom, top, 0.0, (right-left)/2.0);
var x = random(left + dx, right - dx);
var x1 = random(left + dx, right - dx);
// choose the size of the branch according to the position on the tree
var w = map (x, left, right, random(-25) -25, random(25)+25) + 1;
var h = map (y, bottom, top, 5 +random(20), 5);
var w1 = map (x, left, right, random(-35), random(35)) + 3;
var h1 = map (y, bottom, top, random(10), random(10));
// randonize the size
var dw = random(-10, 5);
var dh = random (-5, 5);
var dw1 = random(-5, 1);
var dh1 = random (-1, 1);
// create the new branch
branch(x1, y, w1 + dw1, h1 + dh1);
stroke(random(0),random(128),random(15));
branch(x1, y, w1 + dw1, h1 + dh1);
stroke(random(25),random(255),random(50));
branch(x, y, w + dw, h + dh);
}
}
See More Shortcuts