[INTRO2ICM] WK5 P5JS ROTATE

I wanted to make something that rotates and gets bigger as time goes. So I played with rotate as move in the function and it was not rotating over for loop. So I made display function and rotated at the draw function. As a result, the ellipse moves like a snake following the mouseX and mouseY. Also by mouse-pressed function the ellipse is getting smaller with negative value.

SKETCH>>

var a = 100;
var b = 0;
var c = 190;
var d = 0;
var e = 0.1;
var fshape = [];
function setup() {
createCanvas(900,600);
background(a,b,c);
}

function draw() {

var shape = {

x: d,
y: d,
z: d,

display:function(){
fill(10,100,255);
strokeWeight(1);
stroke(random(150,255),random(200,255),random(0,10));
// quad((this.x+50)/(this.x), mouseX/2, -mouseX/2,-mouseY/2, mouseX/2, mouseY/2, -mouseX/2, -mouseX/2);

//rect(this.x,50,30,this.x);
ellipse(this.x,50,this.x,this.x);
//text(“ITP”, 10 + this.x, 60 + this.x);
},

move:function(){

},
};

translate(mouseX,mouseY);
rotate(d);
shape.display();
shape.move();

d = d+e;

if (mouseIsPressed){
e = -e;
}

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s