Description
This is a modified work that includes drawing function as well as an image of penguins from a website.
Inspiration
1. Draw clouds for Skypman! http://www.openprocessing.org/sketch/95766
2. Image from http://www.biznology.com/wp-content/uploads/2013/08/companions_adelie_penguins.jpg
//////////////////////////////// VARIABLES ////////////////////////////////
// maximum number of mouse points to memorize
int numMaxPoints = 50000;
// array for memorizing mouse points
float pointX[] = new float[numMaxPoints];
float pointY[] = new float[numMaxPoints];
// new(modified) array that is a little bit random from original
float newpointX[] = new float[numMaxPoints];
float newpointY[] = new float[numMaxPoints];
// random Opacity and Size values to memorize for clouds
float randomOpacity[] = new float[numMaxPoints];
float randomSize[] = new float[numMaxPoints];
// number of current points memorized
int numPoints = 0;
// man’s position calculated by curve
float manX[] = new float[numMaxPoints];
float manY[] = new float[numMaxPoints];
// number of man location memorized
int manPoint = 0;
// current frame number
int frameNumber = 0;
//////////////////////////////// SETUP ////////////////////////////////
void setup() {
size(800, 800);
background(149, 215, 255);
// initialize the array
for (int a = 0; a < numMaxPoints; ++a) {
pointX[a] = 0;
pointY[a] = 0;
}
}
//////////////////////////////// FUNCTIONS ////////////////////////////////
void mouseDragged() {
// assign values when mouse is dragged
pointX[numPoints] = mouseX;
pointY[numPoints] = mouseY;
// randomize the points for small clouds
newpointX[numPoints] = pointX[numPoints] + random(-30, 30);
newpointY[numPoints] = pointY[numPoints] + random(-30, 30);
// randomize and memorize other values
randomOpacity[numPoints] = random(10, 50);
randomSize[numPoints] = random(30, 50);
++numPoints;
}
// cloud drawing function
// Send the numPoints value to draw at specific location
void cloud(int i) {
noStroke();
fill (255, 255, 255, random(50, 100));
ellipse(pointX[i] +random(-5, 5), pointY[i] +random(-5, 5), 30, 30);
smallCloud(i);
smallCloud(i);
}
// Draw small clouds surrounding the main clouds
// Send the numPoints value to draw at specific location
void smallCloud(int i) {
if (i > 50) {
fill(255, 255, 255, random(10, 50));
ellipse(newpointX[i-50], newpointY[i-50], randomSize[i-50] +random(-5, 5), randomSize[i-50] +random(-5, 5));
}
}
// the function drawing the smiling man
//////////////////////////////// MAIN DRAW FUNCTION ////////////////////////////////
PImage webImg;
void draw() {
size (1800,1500);
// Load image from a web server
webImg = loadImage(url, “jpg”);
image(webImg, 0, 0);
// Erase memorized points (erase canvas) if right mouse button is clicked
if (mousePressed && (mouseButton == RIGHT)) {
numPoints = 0;
manPoint = 0;
}
// Count the frame number
++frameNumber;
// Print information in console for coding
println(“Frame Number: ” + frameNumber);
println(“Memorized Points(numPoints): ” + numPoints);
// call cloud() to draw clouds
for (int i = 0; i < numPoints; ++i) {
cloud(i);
}
}