Skip to content

Instantly share code, notes, and snippets.

@moziauddin
Last active April 15, 2020 09:26
Show Gist options
  • Save moziauddin/6c5c625145fbb0286424e14562f31378 to your computer and use it in GitHub Desktop.
Save moziauddin/6c5c625145fbb0286424e14562f31378 to your computer and use it in GitHub Desktop.
Processing Examples
PShape ship;
PVector loc, vel;
int shipWidth, shipHeight;
float angle;
void setup() {
size(400,400);
ship = loadShape("ship.svg");
loc = new PVector(width/2, height/2);
vel = new PVector(0,1);
shipWidth = 20;
shipHeight = 30;
angle = 1;
//shapeMode(CENTER);
frameRate(30);
smooth();
}
void draw() {
background(0);
stroke(255,255,0);
strokeWeight(10);
point(loc.x, loc.y);
shape(ship, loc.x, loc.y, shipWidth, shipHeight);
pushMatrix();
//translate(loc.x, loc.y);
ship.rotate(radians(angle));
popMatrix();
println(angle + ": "+radians(angle));
}
int sunSize, earthSize, moonSize;
float r;
void setup() {
size(800,800);
sunSize = 200;
earthSize = 100;
r =0.01;
ellipseMode(CENTER);
}
void draw() {
background(255);
pushMatrix();
translate(width/2,height/2);
rotate(radians(r/10));
fill(255, 255, 0);
ellipse(0,0,sunSize,sunSize);
fill(0, 0, 200);
ellipse(sunSize, sunSize, earthSize,earthSize);
pushMatrix();
translate(sunSize, sunSize);
rotate(radians(r*20));
fill(200);
ellipse(earthSize/2+20, earthSize/2+20, 10,10);
popMatrix();
r+=1;
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment