/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://bard117s14.sketchpad.cc/sp/pad/view/ro.3jk1B0c6TOV/rev.1
*
* authors:
* Christopher Shea
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/*
Chris Shea <[email protected])
Feb. 18, 2014
Self-Portrait II
Comment: This code should do the following: when it begins,
the viewer should see a bald human enjoying a clear
sunny day, and the sun should be happily pulsating.
When the mouse is clicked and held, the "human's" eyes
should turn red, as should the sun, an atenna should extend
from the "human's" head, and the sky should flash stormily.
When the mouse is released, all returns to normal.
This portrait is much more complicatd than the first portrait.
It is no longer a collection of static primitives, but now
contains both a static animation (the pulsating sun) and
interactive animation (those induced by the mouse click).
Furthermore, the sky 'flashing' is achieved by randomizing
the sky's grayscale shade each frame. Likewise, the erratic
behavior of the red sun is achieved by randomizing the
sun's size when the mouse is held.
The picture is dynamic only insofar as there are two randomized
elements (i.e. elements that will not be the same each time
the mouse is clicked and held), but the effect of these 'dynamic'
elements is underwhelming because the randomization happens
so quickly that it seems to only produce 'vibrations' which
are monotonous enough to seem almost static. Even if this were
not the case (that is, even if the dynamic elements were more
interesting), the program would not be a dynamic drawing
in Victor's ideal sense. My 'drawing' was the manipulation
of abstract text, not a direct manipulation of the kind
possible with static images/animation in a program such
as Photoshop. This process can thus be frustrating,
especially for someone inexperienced, and often entails
as much trial-and-error as informed, mathematical intent.
*/
float centerX;
float centerY;
float antX;
float antY;
float sunStep;
float sunSize = 100;
void setup() {
size(600, 800);
smooth();
background(255);
noStroke();
smooth();
ellipseMode(CENTER);
frameRate(30);
// variables
centerX = width/2;
centerY = height/2;
antY= centerY -45;
antX = centerX;
sunStep = 1;
// Grass
fill(37, 200, 25);
rect(0, 600, 600, 400);
}
void draw() {
sunSize = sunSize + sunStep;
// Sky
noStroke();
if (mousePressed) {
fill(random (0, 175), 35);
}
else {
fill(2, 125, 230);
}
rectMode(CORNER);
rect(0, 0, 600, 600);
// Sun
noStroke();
if (mousePressed) {
fill(245, 40, 40);
sunSize = random(100, 150);
}
else {
fill(240, 240, 25);
}
if (sunSize <= 100) {
sunStep = -1 * sunStep;
}
else if (sunSize >= 150) {
sunStep = -1 * sunStep;
}
ellipse(80, 90, sunSize, sunSize);
// Cloud
noStroke();
fill(255);
ellipse(115, 115, 65, 50);
ellipse(150, 100, 75, 65);
ellipse(185, 115, 65, 50);
// Antenna
stroke(0);
strokeWeight(3);
if (mousePressed) {
antY = antY - 3;
}
else {
antY= antY + 3;
}
if (antY <= 300) {
antY = 300;
}
if (antY >= 350) {
antY = 350;
}
line(antX, antY, antX, antY-35);
fill(245, 40, 40);
noStroke();
ellipse(antX, antY-40, 15, 15);
// Shirt
noStroke();
fill(235, 40, 65);
rectMode(CENTER);
rect(centerX, centerY+330, 200, 400);
// Neck
fill(250, 165, 94); // neck tone, darker for contrast
rect(centerX, centerY+100, 60, 74);
// The collar portion of neck
ellipse(centerX, centerY+137, 60, 30);
// Head
fill(250, 172, 98); // skin tone
ellipse(centerX, centerY, 150, 200);
// Eyes
fill(255);
ellipse(centerX-30, centerY-10, 30, 15); //left
ellipse(centerX+30, centerY-10, 30, 15); //right
// Irises
if (mousePressed) {
fill(245, 40, 40);
}
else {
fill(95, 51, 9);
}
ellipse(centerX-30, centerY-10, 10, 10); //left
ellipse(centerX+30, centerY-10, 10, 10); //right
// Nose
stroke(198, 147, 80);
strokeWeight(2);
line(centerX, centerY-10, centerX+8, centerY+30); //long edge
line(centerX, centerY+30, centerX+8, centerY+30);
// Eyebrows
stroke(95, 51, 9);
strokeWeight(2);
line(centerX-45, centerY-25, centerX-15, centerY-25); //left
line(centerX+45, centerY-25, centerX+15, centerY-25); //right
}