Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This program draws a picture called "Bouncing shapeshifter"
- using only basic shapes in Processing. My intention was to
- create an illusion of movement and changes in shape. I have
- also implemented the 4th parameter in fill and stroke
- color - opacity - to get more complex color palette. Created
- by Olaf Keller for the Coursera course: "Introduction to
- Computational Arts: Processing"
- */
- void setup() {
- size(800, 500);
- }
- void draw() {
- background(0);
- fill(255, 255, 255, 2);
- stroke(255, 255, 255, 2);
- triangle(0, 149, 52, 101, 68, 170);
- fill(255, 250, 250, 4);
- stroke(255, 255, 255, 3);
- triangle(0, 149, 66, 124, 56, 194);
- fill(255, 245, 245, 6);
- stroke(255, 255, 255, 6);
- triangle(0, 149, 72, 142, 43, 207);
- fill(255, 240, 240, 8);
- stroke(255, 255, 255, 8);
- triangle(15, 166, 86, 169, 49, 229);
- fill(255, 235, 235, 11);
- stroke(255, 255, 255, 11);
- triangle(31, 197, 101, 206, 58, 263);
- fill(255, 230, 230, 13);
- stroke(255, 255, 255, 13);
- triangle(38, 224, 106, 246, 53, 293);
- fill(255, 225, 225, 15);
- stroke(255, 255, 255, 15);
- triangle(51, 248, 111, 287, 47, 319);
- fill(255, 220, 220, 18);
- stroke(255, 255, 255, 18);
- triangle(38, 339, 61, 272, 108, 325);
- fill(255, 215, 215, 20);
- stroke(255, 255, 255, 20);
- triangle(34, 356, 71, 295, 105, 357);
- fill(255, 210, 210, 22);
- stroke(255, 255, 255, 22);
- triangle(31, 377, 80, 326, 100, 395);
- fill(255, 205, 205, 24);
- stroke(255, 255, 255, 24);
- triangle(46, 376, 107, 341, 107, 412);
- fill(255, 200, 200, 27);
- stroke(255, 255, 255, 27);
- triangle(67, 361, 136, 342, 117, 411);
- fill(255, 190, 190, 29);
- stroke(255, 255, 255, 29);
- triangle(93, 346, 163, 357, 117, 411);
- fill(255, 185, 185, 31);
- stroke(255, 255, 255, 31);
- triangle(115, 341, 178, 374, 117, 411);
- fill(255, 180, 180, 33);
- stroke(255, 255, 255, 33);
- triangle(148, 347, 189, 405, 117, 411);
- fill(255, 175, 175, 35);
- stroke(255, 255, 255, 35);
- quad(128, 378, 157, 323, 219, 356, 190, 411);
- fill(255, 170, 170, 37);
- stroke(255, 255, 255, 37);
- quad(142, 345, 184, 299, 237, 347, 195, 393);
- fill(255, 165, 165, 39);
- stroke(255, 255, 255, 39);
- quad(163, 313, 215, 279, 254, 339, 202, 373);
- fill(255, 160, 160, 41);
- stroke(255, 255, 255, 41);
- quad(185, 298, 244, 280, 264, 348, 205, 366);
- fill(255, 155, 155, 43);
- stroke(255, 255, 255, 43);
- quad(220, 281, 282, 286, 275, 357, 213, 352);
- fill(255, 150, 150, 45);
- stroke(255, 255, 255, 45);
- quad(249, 283, 309, 301, 288, 369, 228, 351);
- fill(255, 145, 145, 47);
- stroke(255, 255, 255, 47);
- beginShape();
- vertex(263, 357);
- vertex(256, 294);
- vertex(319, 290);
- vertex(338, 351);
- vertex(287, 382);
- endShape(CLOSE);
- fill(255, 140, 140, 50);
- stroke(255, 255, 255, 50);
- beginShape();
- vertex(257, 364);
- vertex(285, 305);
- vertex(349, 310);
- vertex(360, 372);
- vertex(303, 406);
- endShape(CLOSE);
- fill(255, 135, 135, 52);
- stroke(255, 255, 255, 52);
- beginShape();
- vertex(269, 366);
- vertex(303, 310);
- vertex(365, 321);
- vertex(370, 384);
- vertex(311, 412);
- endShape(CLOSE);
- fill(255, 130, 130, 54);
- stroke(255, 255, 255, 54);
- beginShape();
- vertex(292, 353);
- vertex(346, 317);
- vertex(398, 353);
- vertex(375, 413);
- vertex(310, 413);
- endShape(CLOSE);
- fill(255, 125, 125, 56);
- stroke(255, 255, 255, 56);
- beginShape();
- vertex(309, 338);
- vertex(365, 308);
- vertex(408, 354);
- vertex(379, 413);
- vertex(318, 403);
- endShape(CLOSE);
- fill(255, 120, 120, 59);
- stroke(255, 255, 255, 59);
- beginShape();
- vertex(324, 328);
- vertex(384, 307);
- vertex(419, 360);
- vertex(381, 413);
- vertex(322, 393);
- endShape(CLOSE);
- fill(255, 115, 115, 61);
- stroke(255, 255, 255, 61);
- beginShape();
- vertex(340, 311);
- vertex(401, 293);
- vertex(433, 347);
- vertex(393, 399);
- vertex(335, 377);
- endShape(CLOSE);
- fill(255, 110, 110, 64);
- stroke(255, 255, 255, 64);
- beginShape();
- vertex(359, 283);
- vertex(417, 257);
- vertex(457, 306);
- vertex(424, 363);
- vertex(364, 349);
- endShape(CLOSE);
- fill(255, 105, 105, 66);
- stroke(255, 255, 255, 66);
- beginShape();
- vertex(378, 324);
- vertex(380, 258);
- vertex(440, 237);
- vertex(475, 290);
- vertex(437, 343);
- endShape(CLOSE);
- fill(255, 100, 100, 68);
- stroke(255, 255, 255, 68);
- beginShape();
- vertex(411, 271);
- vertex(434, 210);
- vertex(497, 208);
- vertex(514, 270);
- vertex(461, 308);
- endShape(CLOSE);
- fill(255, 95, 95, 70);
- stroke(255, 255, 255, 70);
- beginShape();
- vertex(461, 310);
- vertex(445, 254);
- vertex(484, 213);
- vertex(540, 226);
- vertex(557, 282);
- vertex(517, 323);
- endShape(CLOSE);
- fill(255, 90, 90, 72);
- stroke(255, 255, 255, 72);
- beginShape();
- vertex(460, 309);
- vertex(468, 252);
- vertex(522, 230);
- vertex(567, 265);
- vertex(559, 322);
- vertex(506, 344);
- endShape(CLOSE);
- fill(255, 85, 85, 74);
- stroke(255, 255, 255, 74);
- beginShape();
- vertex(490, 358);
- vertex(461, 308);
- vertex(490, 258);
- vertex(547, 258);
- vertex(576, 308);
- vertex(547, 358);
- endShape(CLOSE);
- fill(255, 80, 80, 62);
- stroke(255, 255, 255, 62);
- beginShape();
- vertex(483, 381);
- vertex(470, 325);
- vertex(513, 286);
- vertex(568, 303);
- vertex(581, 359);
- vertex(539, 398);
- endShape(CLOSE);
- fill(255, 70, 70, 65);
- stroke(255, 255, 255, 65);
- beginShape();
- vertex(486, 381);
- vertex(489, 323);
- vertex(541, 297);
- vertex(589, 329);
- vertex(586, 387);
- vertex(534, 413);
- endShape(CLOSE);
- fill(255, 65, 65, 65);
- stroke(255, 255, 255, 65);
- beginShape();
- vertex(501, 368);
- vertex(520, 314);
- vertex(577, 304);
- vertex(614, 348);
- vertex(595, 402);
- vertex(538, 412);
- endShape(CLOSE);
- fill(255, 60, 60, 68);
- stroke(255, 255, 255, 68);
- beginShape();
- vertex(557, 413);
- vertex(524, 379);
- vertex(524, 331);
- vertex(557, 298);
- vertex(604, 298);
- vertex(638, 331);
- vertex(638, 379);
- vertex(604, 413);
- endShape(CLOSE);
- fill(255, 55, 55, 71);
- stroke(255, 255, 255, 71);
- beginShape();
- vertex(572, 405);
- vertex(544, 367);
- vertex(550, 320);
- vertex(588, 291);
- vertex(635, 297);
- vertex(663, 335);
- vertex(657, 382);
- vertex(619, 411);
- endShape(CLOSE);
- fill(255, 50, 50, 74);
- stroke(255, 255, 255, 74);
- beginShape();
- vertex(588, 388);
- vertex(567, 346);
- vertex(582, 300);
- vertex(624, 279);
- vertex(669, 294);
- vertex(690, 336);
- vertex(675, 381);
- vertex(633, 403);
- endShape(CLOSE);
- fill(255, 45, 45, 76);
- stroke(255, 255, 255, 76);
- beginShape();
- vertex(606, 366);
- vertex(592, 321);
- vertex(614, 279);
- vertex(659, 264);
- vertex(701, 286);
- vertex(715, 331);
- vertex(693, 373);
- vertex(648, 388);
- endShape(CLOSE);
- ellipseMode(CENTER);
- fill(255, 40, 40, 78);
- stroke(255, 255, 255, 78);
- ellipse(671, 319, 126, 126);
- fill(255, 35, 35, 80);
- stroke(255, 255, 255, 80);
- ellipse(695, 313, 111, 111);
- fill(255, 30, 30, 82);
- stroke(255, 255, 255, 82);
- ellipse(715, 311, 96, 96);
- fill(255, 25, 25, 84);
- stroke(255, 255, 255, 84);
- ellipse(731, 309, 81, 81);
- fill(255, 20, 20, 86);
- stroke(255, 255, 255, 86);
- ellipse(750, 309, 66, 66);
- fill(255, 15, 15, 88);
- stroke(255, 255, 255, 88);
- ellipse(772, 314, 51, 51);
- fill(255, 10, 10, 90);
- stroke(255, 255, 255, 90);
- ellipse(786, 322, 36, 36);
- fill(255, 5, 5, 92);
- stroke(255, 255, 255, 92);
- ellipse(800, 340, 21, 21);
- fill(255, 0, 0, 94);
- stroke(255, 255, 255, 94);
- ellipse(800, 350, 6, 6);
- }
- /* Functions below create and save the output as a normal .png file
- and high resolution .png when 's' key is pressed - code by Amnon Owed:
- http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/
- */
- void keyPressed() {
- if (key == 's') {
- save("normal2.png");
- saveHiRes(2);
- exit();
- }
- }
- void saveHiRes(int scaleFactor) {
- PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
- beginRecord(hires);
- hires.scale(scaleFactor);
- draw();
- endRecord();
- hires.save("hires.png");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement