previous

page 17

next
adding colour
function vee(d,w) {
if (d>10) {
var f=.8;
var dlim=20;
pw(w); pc('brown');
if (d<dlim) pc('lime');
lt(30);
fd(d); vee(d*f,w*f);
pw(w); pc('brown');
if (d<dlim) pc('lime');
bk(d); rt(60);
fd(d); vee(d*f,w*f);
pw(w); pc('brown');
if (d<dlim) pc('lime');
bk(d); lt(30);
}
}
function tree() {
pc('brown');
pu(); bk(350); pd();
pw(4); fd(150); vee(100,4);
}
add a lttle randomness
// Returns a random integer between
// min (included) and max (included)
function Rand(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function vee(d,w) {
d=Rand(d-3,d+3);
if (d>10) {
...
}
previous
next