AirBoss Gif
So this assignment was really a challenge for me because, well, I’ve only ever made animated cursors through a simple program before. I still feel very limited in the amount of things I know how to do, but learning the applications of code one step at a time is really thrilling.
The plane shape I drew was really simple in the fact that I just used beginShape() and endShape, along with a few arcs. I wanted to take it one step further and add shading or curvature, but I have yet to fully comprehend the PShader tutorial on Processing.org. I learned most of the stuff in this code from Lynda.com and Golan.
I do realize that this is not a perfect loop… I’m working on it…
Here’s a sketch of my original idea:
Code:
PFont myFont;
int X_AXIS=1;
int Y_AXIS=2;
float theta=0;
color[] sky={#155484,#79a4c5};
void setup() {
size(600,300);
myFont=loadFont("Optima-BoldItalic-22.vlw");
textFont(myFont);
frameRate(30);
}
void draw(){
//if (frameCount< =60) {
// saveFrame("plane-####.png");
//}
setGradient(0,0,width,height,sky[0],sky[1],Y_AXIS); //sky backdrop
float a=map(sin(theta),-1,1,-12,12);
theta+=0.06;
pushMatrix();
scale(1.8);
translate(0,-80);
rotate(radians(3));
drawClouds(250,40,0.006,0.60);
popMatrix();
pushMatrix();
rotate(radians(7));
translate(a,1.5*a);
drawPlane();
popMatrix();
pushMatrix();
translate(0,50);
scale(2.0);
rotate(radians(8));
drawClouds(250,80,0.03,0.3);
popMatrix();
}
//Learned from processing.org examples
void setGradient(int x, int y, float w, float h, color c1, color c2, int axis) {
noFill();
if(axis==X_AXIS){
for(int i=x;i< =x+w;i++){
float inter=map(i,x,x+w,0,1);
color c=lerpColor(c1,c2,inter); //inter is between 0.0 and 1.0
stroke(c);
line(i,y,i,y+h);
}
}
else if(axis==Y_AXIS){
for(int i=y;i<=y+h;i++){
float inter=map(i,y,y+h,0,1);
color c=lerpColor(c1,c2,inter);
stroke(c);
line(x,i,x+w,i);
}
}
}
//Learned from Golan!! Thanks!!
void drawClouds(int col,int tra,float speed,float thresh){ //color, transparency, speed, threshold
fill(col,tra);
noStroke();
for(int i=0;i