Sunday, November 24, 2013

Project 4 critique

I wasn't completely happy with my project because I couldn't get it to do exactly what I wanted it to. Barry suggested that I might have to have the user put the animals on the page without seeing them first. He also suggested that I make them bigger and maybe make an array of different backgrounds to use. I explained that I made them the size that I did to fit with the background I was using. They could be used in different sizes with different backgrounds. Since they didn't work right with the svg file type, I would need to have different size png files to use or find out what the error I got with the svg means and if there is a work around for it.
I think it would be easy to make it have several backgrounds. I'd prefer to let the user see the animals before placing them, but maybe there would be a way to show the various animals first, pick one to place and where to place it. My problem with this project was that processing keeps running the draw and makes the key press last for more than one cycle through draw. That makes it hard to assign values to an array while running. I solved that by placing animals in an array first and then the user just had to chose them and the program found it instead of putting it in the draw function.

Wednesday, November 6, 2013

A processing project I like

Here's a link to a project I like:  http://www.openprocessing.org/sketch/110146 This project is by carrie chang. The code is easy, so anyone in class could make this. I like it because it looks really cool.
The first part of the code makes a black background and a shape with many triangles with a white stroke. After that more triangles are added on top of it which are different shades of red, pink, purple and orange.

Monday, November 4, 2013

Project 3

I think the critique went well. Barry said that I should make the font bigger for reading when displaying to the class. I will keep that in mind for any text I use on the next project. I was able to make this project do everything that I wanted it to. If I were to extend it I'd make it pause to make it easier to make a screenprint. Also, I had to comment out the part that used coded keys to make screen prints of it because I had them clear the screen. This caused the screen to be cleared when trying to take a screen shot until I commented it out. I think I'd prefer to work on something else for the next project rather than extending this.
I used techniques not discussed in class in making my project like writing my own functions. For others in the class who don't know me, I have a degree in computer science and engineering and worked as a programmer for 3 1/2 years. Even though I am new to processing and only used Java in a class back in the 90s, I have general knowledge of how to go about programming so learning this is mostly becoming familiar with the syntax for me.
Here are some screen shots of my project:


 
Here is the code:
 
 float angle=0.0;
float r;
float s;
float t;
String shape;
String direction;
PFont font;
void setup(){
  size(600,600);
  background(0); //set background to black
  smooth();
  font = loadFont("TimesNewRomanPSMT-48.vlw");
  textFont(font);
  textSize(18);
  text("Press t for triangles, e for ellipses and q for quads.  Move by using the mouse. Press a coded key to clear the screen. Press 1 to rotate in a clockwise direction and any other key to rotate counterclockwise.",75,150,450,300); 
}
void draw(){
  translate(mouseX, mouseY); //move axis to mouse location
  rotate(angle);   //rotate axis
  r=random(255);      //set 3 random numbers changes every time run
  s=random(255);
  t=random(255);
  fill(int(r),int(s),int(t));  /*convert random numbers to int and
                                 use to generate random color*/
                                
  if (shape == "triangle"){                              
    triangle(20,20,60,150,85,115);  //show triangle
  }
  if (shape == "quad"){
     quad(30,30,60,90,150,150,300,100);  //show quad
   }
   if (shape == "ellipse"){
     ellipse(10,10,150,225);  //show ellipse
   }
   if (direction =="counterclockwise"){
     angle += 0.1;
   } else{
       direction ="clockwise";
       angle -=0.1;
   }
      
  if (keyPressed && (key == CODED) ) {
   // background(0);  //clear screen
    }
    if (keyPressed){
      if (key == '1'){
      direction = "clockwise";  //change rotation direction 
       } else {
       direction ="counterclockwise";
       } 
    }
  if (keyPressed){
    if ((key == 'q')||(key == 'Q' )) {
      shape = "quad";
    }
    if ((key == 'e') ||(key == 'E')){
      shape = "ellipse";
      } else
      if((key == 't')||(key =='T')){
      shape = "triangle";
      }
   }
   displayShape(shape);
   selectDirection(direction);
     }
//This function sets the shape displayed
String displayShape(String shape){
    String newShape;
    newShape = shape; 
    return newShape;
  }
//This function selects the direction of rotation 
String selectDirection(String direction){
   String newDirection;
   newDirection = direction;
   return newDirection;
 }