proce55or

Untitled

Feb 4th, 2014
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. /* This program creates an image (using only squares)
  2.  that contains three colors from a Shades palette
  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 canvas size
  11.   size(600, 600);
  12. }
  13.  
  14. void draw() {
  15.   //set background to black
  16.   background(0);
  17.  
  18.   //this part of code draws 4 squares
  19.   // set stroke to black for the next 3 squares
  20.   stroke(0);
  21.  
  22.   //square 1
  23.   fill(#FFAA1A);
  24.   strokeWeight(11);
  25.   rect(0, 0, 580, 580);
  26.  
  27.   //square 2
  28.   fill(#7F550D);
  29.   strokeWeight(10);
  30.   rect(50, 50, 520, 520);
  31.  
  32.   //square 3
  33.   fill(#BF7F13);
  34.   strokeWeight(30);
  35.   rect(100, 100, 400, 400);
  36.  
  37.   //square 4
  38.   fill(#E59917);
  39.   strokeWeight(50);
  40.   stroke(#FFAA1A);
  41.   rect(150, 200, 200, 200);
  42. }
  43.  
  44. /* Functions below create and save the output as a normal .png file
  45.  and high resolution .png when 's' key is pressed - code by Amnon Owed:
  46.  http://amnonp5.wordpress.com/2012/01/28/25-life-saving-tips-for-processing/
  47.  */
  48.  
  49. void keyPressed() {
  50.   if (key == 's') {
  51.     save("normal.png");
  52.     saveHiRes(5);
  53.     exit();
  54.   }
  55. }
  56.  
  57. void saveHiRes(int scaleFactor) {
  58.   PGraphics hires = createGraphics(width*scaleFactor, height*scaleFactor, JAVA2D);
  59.   beginRecord(hires);
  60.   hires.scale(scaleFactor);
  61.   draw();
  62.   endRecord();
  63.   hires.save("hires.png");
  64. }
Advertisement
Add Comment
Please, Sign In to add comment