Skip to content

Instantly share code, notes, and snippets.

@bevchou
Created November 28, 2017 08:34
Show Gist options
  • Save bevchou/115593a395f8f65bc3cb49c55940f794 to your computer and use it in GitHub Desktop.
Save bevchou/115593a395f8f65bc3cb49c55940f794 to your computer and use it in GitHub Desktop.
class Imgcloud {
constructor(img, r, theta, theta_vel) {
//pass to class
this.img = img;
this.r = r;
this.theta = theta;
this.theta_vel = theta_vel;
//other variables
this.x = 0;
this.y = 0;
this.randomRotate = random(-PI/2, PI/2);
}
run() {
this.convertToRad();
this.update();
this.show();
}
convertToRad() {
this.x = this.r * cos(this.theta);
this.y = this.r * sin(this.theta);
}
update() {
this.theta += this.theta_vel;
}
show() {
push();
// translate(-imgW / 2, -imgW / 2);
rotate(this.randomRotate);
tint(255, 190);
image(this.img, this.x, this.y, imgW, imgW);
pop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment