/*
Victoria Reiter
Section B
vreiter@andrew.cmu.edu
Assignment-10-b
*/
// makes turtle
var turtle;
// angle for the pretty plant design thing!
var chooseAngle = 200;
//makes plus shape
function plus() {
turtle.penDown();
turtle.forward(5);
turtle.left(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.left(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.left(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
turtle.left(90);
turtle.forward(5);
turtle.right(90);
turtle.forward(5);
}
function setup() {
createCanvas(600, 400);
background(80, 0, 255);
// makes turtle at center of canvas
turtle = makeTurtle(width / 2, height / 2);
turtle.setColor(color(202, 255, 112, 80));
turtle.setWeight(.25);
turtle.penUp();
}
function draw() {
plus(20, 30);
for (var i = 0; i < 100; i++) {
var distt = mouseX / 7;
turtle.penUp();
turtle.forward(distt);
plus();
turtle.penUp();
// returns turtle to center so it progressively moves greater distances
turtle.back(distt);
// rotates by golden angle
turtle.left(chooseAngle);
}
}
// --------------------------------
function turtleLeft(d){this.angle-=d;}function turtleRight(d){this.angle+=d;}
function turtleForward(p){var rad=radians(this.angle);var newx=this.x+cos(rad)*p;
var newy=this.y+sin(rad)*p;this.goto(newx,newy);}function turtleBack(p){
this.forward(-p);}function turtlePenDown(){this.penIsDown=true;}
function turtlePenUp(){this.penIsDown = false;}function turtleGoTo(x,y){
if(this.penIsDown){stroke(this.color);strokeWeight(this.weight);
line(this.x,this.y,x,y);}this.x = x;this.y = y;}function turtleDistTo(x,y){
return sqrt(sq(this.x-x)+sq(this.y-y));}function turtleAngleTo(x,y){
var absAngle=degrees(atan2(y-this.y,x-this.x));
var angle=((absAngle-this.angle)+360)%360.0;return angle;}
function turtleTurnToward(x,y,d){var angle = this.angleTo(x,y);if(angle< 180){
this.angle+=d;}else{this.angle-=d;}}function turtleSetColor(c){this.color=c;}
function turtleSetWeight(w){this.weight=w;}function turtleFace(angle){
this.angle = angle;}function makeTurtle(tx,ty){var turtle={x:tx,y:ty,
angle:0.0,penIsDown:true,color:color(128),weight:1,left:turtleLeft,
right:turtleRight,forward:turtleForward, back:turtleBack,penDown:turtlePenDown,
penUp:turtlePenUp,goto:turtleGoTo, angleto:turtleAngleTo,
turnToward:turtleTurnToward,distanceTo:turtleDistTo, angleTo:turtleAngleTo,
setColor:turtleSetColor, setWeight:turtleSetWeight,face:turtleFace};
return turtle;}
///GRACE DAY TAKEN///
For this week’s project I took inspiration from the “golden angle” and natural angles of plants and things in nature from last week. I wanted to know what it would be like if I manipulated it to work through an angle of my choosing, and other aspects of my choosing, such as a plus shape instead of hexagons. I made the stroke weight very fine and the opacity more sheer to add added effects. I also introduced animation by incorporating variation with mouseX.
I think this design is interesting because as you move the mouse, it looks as though there is a flower itself in the middle rotating around and around, but really it’s just the shapes building on themselves. How interesting!
((This is unrelated but I went to the Children’s Museum today and saw the Letter Rain mentioned in the Deliverables for the week and that wE. cOdED. so I thought that was cool! Here’s a quick picture just for fun hehehe))