void turtle() { P5JSExtension.background(51); P5JSExtension.resetMatrix(); P5JSExtension.translate(P5JSExtension.width / 2, P5JSExtension.height); P5JSExtension.stroke(255); for (int i = 0; i < sentence.Length; i++) { var current = sentence[i]; if (current == 'F') { P5JSExtension.line(0, 0, 0, -len); P5JSExtension.translate(0, -len); } else if (current == '+') { P5JSExtension.rotate(angle); } else if (current == '-') { P5JSExtension.rotate(-angle); } else if (current == '[') { P5JSExtension.push(); } else if (current == ']') { P5JSExtension.pop(); } } }
public void show() { if (parent != null) { P5JSExtension.stroke(255); P5JSExtension.line(this.pos.x, this.pos.y, this.parent.pos.x, this.parent.pos.y); } }
public void show() { float thick = P5JSExtension.map(z, 0, 20, 1, 3); P5JSExtension.strokeWeight(thick); P5JSExtension.stroke(138, 43, 226); P5JSExtension.line(x, y, x, y + len); }
void branch(float len) { P5JSExtension.line(0, 0, 0, -len); P5JSExtension.translate(0, -len); if (len > 4) { P5JSExtension.push(); P5JSExtension.rotate(angle); branch(len * 0.67f); P5JSExtension.pop(); P5JSExtension.push(); P5JSExtension.rotate(-angle); branch(len * 0.67f); P5JSExtension.pop(); } }
public void Show() { float sx = P5JSExtension.map(x / z, 0, 1, 0, P5JSExtension.width); float sy = P5JSExtension.map(y / z, 0, 1, 0, P5JSExtension.height); float r = P5JSExtension.map(z, 0, P5JSExtension.width, 16, 0); //translate canvas sx += P5JSExtension.width / 2; sy += P5JSExtension.height / 2; P5JSExtension.ellipse(sx, sy, r, r); float px = P5JSExtension.map(x / pz, 0, 1, 0, P5JSExtension.width); float py = P5JSExtension.map(y / pz, 0, 1, 0, P5JSExtension.height); pz = z; //translate canvas px += P5JSExtension.width / 2; py += P5JSExtension.height / 2; P5JSExtension.line(px, py, sx, sy); }
public void show() { P5JSExtension.stroke(255); P5JSExtension.line(this.begin.x, this.begin.y, this.end.x, this.end.y); }