proce55or

Untitled

Feb 4th, 2014
732
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1. /* This program draws a picture called "Nude Triangle Descending a Staircase"
  2.  using triangle(); and other associated codes.
  3.  Created by Olaf Keller for the Kunstwurfelspiel Academy course:
  4.  "Creating Geometric and Generative Art with Code:
  5.  An Introduction to Processing Software"
  6.  */
  7.  
  8.  
  9. void setup() {
  10.   //set size
  11.   size(600, 600);
  12.   //set anti-aliasing on
  13.   smooth();
  14. }
  15.  
  16. void draw() {
  17.   //set background to black
  18.   background(0);
  19.   //set stroke color to white and alpha 30
  20.   stroke(255, 30);
  21.  
  22.   //this part of code draws triangles, where every
  23.   //triangle becomes brighter and less transparent
  24.   fill(15, 5);
  25.   triangle(169, 184, 272, 3, 376, 183);
  26.   fill(30, 10);
  27.   triangle(169, 184, 297, 20, 375, 213);
  28.   fill(45, 15);
  29.   triangle(169, 184, 316, 37, 369, 238);
  30.   fill(60, 20);
  31.   triangle(169, 184, 340, 66, 356, 273);
  32.   fill(75, 25);
  33.   triangle(169, 184, 360, 102, 336, 308);
  34.   fill(90, 30);
  35.   triangle(169, 184, 373, 138, 312, 336);
  36.   fill(105, 35);
  37.   triangle(169, 184, 376, 170, 285, 357);
  38.   //fill this triangle to red and alpha 40
  39.   fill(255, 0, 0, 40);
  40.   triangle(169, 184, 376, 183, 273, 363);
  41.   fill(135, 45);
  42.   triangle(167, 194, 375, 195, 271, 375);
  43.   fill(150, 50);
  44.   triangle(165, 207, 372, 218, 259, 392);
  45.   fill(165, 55);
  46.   triangle(169, 227, 374, 269, 243, 421);
  47.   fill(180, 60);
  48.   triangle(179, 247, 376, 313, 221, 451);
  49.   fill(195, 65);
  50.   triangle(192, 268, 376, 364, 201, 476);
  51.   fill(210, 70);
  52.   triangle(205, 289, 373, 412, 183, 496);
  53.   fill(225, 75);
  54.   triangle(231, 319, 374, 469, 172, 518);
  55.   fill(240, 80);
  56.   triangle(245, 373, 375, 535, 169, 567);
  57.   fill(255, 90);
  58.   triangle(252, 402, 356, 582, 148, 582);
  59. }
  60.  
  61. /* Functions below create and save the output as a normal .png file
  62.  and high resolution .png when 's' key is pressed - code by Amnon Owed:
  63.  http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/
  64.  */
  65.  
  66. void keyPressed() {
  67.   if (key == 's') {
  68.     save("normal.png");
  69.     saveHiRes(5);
  70.     exit();
  71.   }
  72. }
  73.  
  74. void saveHiRes(int scaleFactor) {
  75.   PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
  76.   beginRecord(hires);
  77.   hires.scale(scaleFactor);
  78.   draw();
  79.   endRecord();
  80.   hires.save("hires.png");
  81. }
Advertisement
Add Comment
Please, Sign In to add comment