xxxxxxxxxx
44
class Command {
constructor(chr, len, level) {
this.chr = chr
this.length = len;
this.angle = angle;
this.homeAngle = angle;
this.moveCount = 0; // initiliazed based on where you are in the tree or perlin noise?
this.level = level;
this.offset = 0;
}
// TO-DO Need to add smooth variation! But maybe SIN is the wrong way to go?
jitter() {
if (this.angle) {
this.moveCount += 0.1;
this.offset = map(sin(this.moveCount),-1,1,0,0.05);
//this.offset = map(mouseX,0,width,0,0.05);
// instead of mouseX it's perlin noise?
//this.angle = this.homeAngle + offset;
// console.log(this.angle);
}
}
run() {
if (this.chr == "F") {
stroke(this.level % 255);
line(0, 0, 0, -this.length);
fill(255);
noStroke();
//text(this.level, 0, 0);
translate(0, -this.length);
} else if (this.chr == "+") {
rotate(this.angle+this.offset);
} else if (this.chr == "-") {
rotate(-this.angle+this.offset)
} else if (this.chr == "[") {
push();
} else if (this.chr == "]") {
pop();
}
}
}