/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://bard117s14.sketchpad.cc/sp/pad/view/ro.pLoUbpTIk8Y/rev.4
*
* authors:
* Sarah D.
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// This sketch builds on a prior work, "Self Portrait II", created by Keith O'Hara
// http://bard117s14.sketchpad.cc/sp/pad/view/ro.AfNeVls4vddifn/rev.71
/*Sarah Davin
*2/16/14
*[email protected]
*Assignment 4: Self Portrait II
*This Self portrait should be able to darken the background
*color with the click of a mouse, lighten the background color
*with the press of a key, make the alien's jewel flash randomly,
* and the eyes should follow the position of the cursor.
*/
//Background Color
float r = 10;
float b = 175;
float g = 256;
float t = 0;
//Jewel
float jewelr=200;
float jewelb=0;
float jewelg=100;
//Eyes
float xLeft=210;
float yLeft=150;
float xRight=285;
float yRight=150;
void setup() {
size(500, 273);
frameRate(60);
smooth();
}
//If mouse pressed, make background darker.
void draw() {
background(r, b, g);
if (mousePressed) {
r= r-4;
b= b-4;
g= g-4;
}
//If key pressed, make background lighter.
if (keyPressed) {
r=r+4;
b=b+4;
g=g+4;
}
//alien's neck
stroke(180, 196, 120);
fill(180, 196, 120);
rect(220, 200, 60, 60);
fill(200, 216, 140);
rect(221, 200, 15, 60);
fill(180, 196, 120);
//alien's shoulders
stroke(25);
line(218, 261, 280, 261);
line(215, 262, 283, 262);
line(210, 263, 286, 263);
line(210, 264, 286, 264);
line(207, 265, 287, 265);
stroke(180, 196, 120);
line(205, 266, 291, 266);
line(205, 267, 291, 267);
line(189, 268, 305, 268);
line(188, 269, 306, 269);
line(185, 270, 308, 270);
line(170, 271, 323, 271);
rect(170, 271, 152, 50);
//alien's left antennae
line(190, 150, 185, 40);
line(191, 150, 186, 40);
line(192, 150, 187, 40);
line(193, 150, 188, 40);
line(194, 150, 189, 40);
line(195, 150, 190, 40);
line(196, 150, 191, 40);
fill(200, 216, 140);
ellipse(188, 40, 10, 10);
//alien's right antennae
fill(180, 196, 120);
line(310, 150, 315, 40);
line(309, 150, 314, 40);
line(308, 150, 313, 40);
line(307, 150, 312, 40);
line(306, 150, 311, 40);
line(305, 150, 310, 40);
line(304, 150, 309, 40);
fill(200, 216, 140);
ellipse(312, 40, 10, 10);
//alien head
stroke(180, 196, 120);
fill(190, 206, 130);
ellipse(250, 150, 165, 195);
fill(200, 216, 140);
stroke(200, 216, 140);
ellipse(250, 150, 160, 190);
stroke(220, 256, 110);
fill(220, 256, 110);
ellipse(250, 150, 155, 185);
//alien's left eye
fill(20);
ellipse(215, 150, 40, 25);
//easing left pupil
float vx = .1*(mouseX-xLeft);
float vy= .1*(mouseY-yLeft);
xLeft=xLeft+vx;
yLeft=yLeft+vy;
xLeft=constrain(xLeft, 202, 228);
yLeft=constrain(yLeft, 144, 156);
fill(246);
ellipse(xLeft, yLeft, 12, 6);
//alien's right eye
fill(20);
ellipse(290, 150, 40, 25);
//easing right pupil
float vxb = .1*(mouseX-xRight);
float vyb = .1*(mouseY-yRight);
xRight=xRight+vxb;
yRight=yRight+vyb;
xRight=constrain(xRight, 275, 303);
yRight=constrain(yRight, 144, 156);
fill(246);
ellipse(xRight, yRight, 12, 6);
//nose
stroke(180, 196, 120);
line(240, 170, 260, 170);
line(242, 171, 258, 171);
line(245, 172, 255, 172);
line(248, 173, 254, 172);
line(251, 174, 249, 173);
//mouth
stroke(20);
line(240, 200, 260, 200);
line(240, 200, 237, 198);
line(260, 200, 263, 198);
stroke(180, 196, 120);
line(246, 205, 254, 205);
line(248, 206, 252, 206);
//left eyebrow
stroke(190, 206, 130);
line(232, 140, 235, 140);
line(230, 139, 236, 139);
line(228, 138, 237, 138);
stroke(180, 196, 120);
line(195, 128, 235, 130);
line(197, 129, 236, 131);
line(205, 130, 237, 132);
line(220, 131, 237, 133);
line(230, 132, 237, 134);
line(234, 133, 236, 135);
//right eyebrow
stroke(190, 206, 130);
line(268, 140, 271, 140);
line(266, 139, 273, 139);
line(264, 138, 275, 138);
stroke(180, 196, 120);
line(266, 130, 306, 128);
line(264, 131, 307, 129);
line(266, 132, 272, 130);
line(265, 132, 292, 130);
line(264, 133, 268, 131);
line(264, 134, 270, 132);
//alien's necklace jewel
stroke(100, 0, 50);
//Make jewel blink.
fill(jewelr, jewelb, jewelg);
jewelr = random(200);
jewelg= random(100);
ellipse(250, 264, 15, 15);
fill(250, 100, 200);
stroke(250, 100, 200);
ellipse(247, 262, 5, 5);
//Stars and Moon
stroke(200);
ellipse(82, 65, 2, 2);
ellipse(140, 70, 2, 2);
ellipse(86, 95, 2, 2);
ellipse(130, 102, 2, 2);
ellipse(55, 56, 2, 2);
ellipse(35, 46, 2, 2);
ellipse(5, 50, 2, 2);
ellipse(400, 100, 2, 2);
ellipse(440, 130, 2, 2);
ellipse(391, 160, 2, 2);
ellipse(400, 159, 2, 2);
ellipse(410, 158, 2, 2);
ellipse(365, 200, 2, 2);
ellipse(420, 220, 2, 2);
fill(200);
ellipse(450, 50, 35, 35);
fill(r, b, g );
stroke(r, b, g);
ellipse(460, 50, 33, 33);
}