/* 
 Press keys 1-6. The idea behind this design was shattered
 glass. Like broken glass, this design has a random pattern
 to it. The one thing I thought was interesting about
 broken glass is that you never know what area is going to
 break. So by pressing keys 1-6 and holding some down for a 
 long time can create different shattered effects.
 */


import proxml.*;
import candy.*;

char c = '1';

SVG glass1;
SVG glass2;

void setup() {
  size(400, 400);
  background(0);
  smooth();
  loop();
  glass1 = new SVG("glass1.svg",this);
  glass2 = new SVG("glass2.svg",this);
} 

void draw() {
}

void keyPressed() {
  if ((keyPressed == true) && (key == '1')) {
    c = key;
    pushMatrix();
    frameRate(50);
    translate(400, 100);
    glass1();
    popMatrix();
  }

  if ((keyPressed == true) && (key == '2')) {
    c = key;
    translate(100, 100);
    glass2();
  }

  if ((keyPressed == true) && (key == '3')) {
    c = key;
    rotate(PI/3);
    translate(200, 10);
    glass1();
  }

  if ((keyPressed == true) && (key == '4')) {
    c = key;
    scale(0.5);
    translate(400, 10);
    rotate(PI/3);
    glass2();
  }

  if ((keyPressed == true) && (key == '5')) {
    c = key;
    translate(300, 0);
    rotate(PI/5);
    glass1();
  }

  if ((keyPressed == true) && (key == '6')) {
    c = key;
    scale(random(0.5, 1.5));
    translate(random(0, 400), random(400, 0));
    rotate(PI/5);
    glass1();
  }
}

void keyReleased() {
  scale(0.5);
  frameRate(2);
  rotate(PI/3);
  translate(0, 0);
  glass1();
  frameRate(2);
  rotate(PI/3);
  translate(0, 0);
  glass2();
}

//////////////////////////////////////////////////////

void glass1() {
  glass1.customStyle();
  smooth();
  fill(150, 150, 150, 50);
  stroke(200);
  strokeCap(ROUND);
  strokeWeight(random(0.5, 2));
  glass1.draw();
}

void glass2() {
  glass2.customStyle();
  smooth();
  fill(150, 150, 150, 10);
  stroke(50);
  strokeCap(ROUND);
  strokeWeight(random(1, 5));
  glass2.draw();
}
Exercise 09: Create a black-and-white abstract image that changes in response to input from the keyboard. Utilize the keyPressed() and keyReleased() functions.