//Michael Shaub //August 19, 2007 //---------------------------------- //Based on code by Daniel Shiffman //---------------------------------- class Turtle { String todo; float len; float theta; float tempLen; Turtle(String s, float l, float t) { todo = s; len = l; theta = t; } void render() { strokeWeight(1.5); stroke(0,255,0); for (int i = 0; i < todo.length(); i++) { char c = todo.charAt(i); println("char c = "+ c); if(i < todo.length()-1){ char d = todo.charAt(i+1); println("char d = "+ d); if (c == 'F' && d == 'X' || c == 'X' && d == 'F') { tempLen = len*lenX; println("tempLen = "+ tempLen); }else{ tempLen = len; } }else{ tempLen = len; } if (c == 'F') { line(0,0,tempLen,0); translate(tempLen,0); } else if (c == '+') { rotate(theta); } else if (c == '-') { rotate(-theta); } else if (c == '[') { pushMatrix(); } else if (c == ']') { popMatrix(); } } } void setLen(float l) { len = l; } void changeLen(float percent) { len *= percent; } void setToDo(String s) { todo = s; } }