pentigreelsystem.pde
来自「This is processing for java examples.」· PDE 代码 · 共 72 行
PDE
72 行
class PentigreeLSystem extends LSystem { int steps = 0; float somestep = 0.1; float xoff = 0.01; PentigreeLSystem() { axiom = "F-F-F-F-F"; rule = "F-F++F+F-F-F"; startLength = 60.0; theta = radians(72); reset(); } void useRule(String r_) { rule = r_; } void useAxiom(String a_) { axiom = a_; } void useLength(float l_) { startLength = l_; } void useTheta(float t_) { theta = radians(t_); } void reset() { production = axiom; drawLength = startLength; generations = 0; } int getAge() { return generations; } void render() { translate(width/4, height/2); steps += 3; if (steps > production.length()) { steps = production.length(); } for (int i = 0; i < steps; i++) { char step = production.charAt(i); if (step == 'F') { noFill(); stroke(255); line(0, 0, 0, -drawLength); translate(0, -drawLength); } else if (step == '+') { rotate(theta); } else if (step == '-') { rotate(-theta); } else if (step == '[') { pushMatrix(); } else if (step == ']') { popMatrix(); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?