Recitation 7: Functions and Arrays by Eleanor Wade

Creating an interesting design with processing is not necessarily something new, so this was not too difficult for me.  Although I still found this to be very time consuming, even though I have become somewhat more familiar with coding and creating designs that do not include animated elements.  Looking back, I think I spent way too much time trying to come up with a design and making it fit into the right place on the background, considering how long it took me to figure out the much more complicated steps in this processing exercise.  I should have read through everything first and made this initial step more efficiently.  

In creating a for loop () I definitely encountered a few problems, because the variable i is in the for loop, the setup has to take from these previous points.  So it knows that I have the variable i in the for loop, but I was struggling with creating the 100 instances.  

int instances = 100;

float [] x = new float [instances];
float [] y = new float [instances];
float [] speedX = new float [instances];
float [] speedY = new float [instances];
color c;

//float [] xPositions = new float [instances];

void setup() {
  size(600, 600);
  background(255);
  for (int i= 0; i < instances; i++) { 
    x [i] = random(width);
    y [i] = random(height);
    speedX [i] = random(5, -5);
    speedY [i] = random(5, -5);
  }
}
void draw() {
  for (int i= 0; i < instances; i++) {
    thing(x [i], y [i], 150, color(150));
    x [i]= x[i] +speedX[i];
    y [i]= y[i] +speedY[i];

    if (x [i] > width || x [i]< 0) {
      speedX[i] = -speedX[i];
    }

    if (y [i] > height || y [i] < 0) {
      speedY[i] = -speedY[i];
    }
  }
}
void thing(float u, float v, float size, color c) {
  // display ball
  strokeWeight(.06);
  fill(c);
  triangle(u, v, size, size, 100, 200 );
  fill(255, 100, 89);
  rect(u-size*0.3, v-size*0.1, 0.05*size, 0.05*size);
  fill(20, 230, 140);
  ellipse(u+size*0.3, v-size*0.1, 0.05*size, 0.05*size);
}

Question 1:

In your own words, please explain the difference between having your for loop from Step 2 in setup() as opposed to in draw().

The key differences between having the for loop in  setup() as opposed to draw () is that when it is in setup it will only run once, while in draw it will continue to do the same thing over and over again. 

Question 2:

What is the benefit of using arrays?  How might you use arrays in a potential project?

Using arrays is beneficial in coding as it is a way to store many data for the set and create infinite of number of repetitive animation without having to recode each design.  This could be used in a project in that you could animate many different different designs that repeat.  Although I have found arrays fairly difficult to use as I am not totally sure where the different variables should be, I definitely plan to use these function in future projects as it is especially useful to save both time and energy in the coding process.  

Recitation 7—-Tao Wen

Question 1:

When the for loop is only in setup(), the graphic will only repeat 100 times. However, if there’s another loop under void draw(), than the action of “repeating 100 times” itself would be repeated 100 times, so the number of graphics is HUGE.

Question 2:

The benefit of using arrays is enabling us to store a number of data that satisfy certain requirements, so that we can pick data to fulfill a function in our own way. 

I would probably set a number of quizes in my project. When the user-controlled robot bumps into something, a question would jump out and the user has to answer it correctly in order to make the next move. Arrays can help me store a certain number of questions, so that they can pop out in a certain order or randomly, according to the way I want it.

Step 1

float x;
float y;
float r;

void setup(){
size(800,800);
background(255);
  colorMode(HSB);
}

void draw() {  
  display(200, width*0.25,  color(145,207,250),width*0.75);
  display(100, width*0.75,  color(250,106,166), width*0.75);
  display(400,height/5,  color(250,106,166),width*0.25);
}

void display(float x, float y, color c,float r) {
  fill(c);
  stroke(0);
  strokeWeight(5);
  rect(x,y,r,r);
  arc(x, y, r*0.6, r*0.6, 0, PI-QUARTER_PI);
  stroke (0);
  strokeWeight(5);
  rect(x+r*0.1,y-r*0.2,r*0.1, r*0.2);
  rect(x-r*0.1,y-r*0.2,r*0.1, r*0.2);
  ellipse(x-r*0.05,y-r*0.1,r*0.01, r*0.02);
  ellipse(x+r*0.15,y-r*0.1,r*0.01, r*0.02);
  delay(1);
}

Step 2

float x;
float y;
float r;

void setup(){
size(800,800);
background(255);

for(int i = 0; i < 100; i = i+1) {
    display((random(width)),(random(height)),color(round(random(255)),175,255),random(255));
} 
  colorMode(HSB);
}

void display(float x, float y, color c,float r) {
  fill(c);
  stroke(0);
  strokeWeight(5);
  rect(x,y,r,r);
  arc(x, y, r*0.6, r*0.6, 0, PI-QUARTER_PI);
  stroke (0);
  strokeWeight(5);
  rect(x+r*0.1,y-r*0.2,r*0.1, r*0.2);
  rect(x-r*0.1,y-r*0.2,r*0.1, r*0.2);
  ellipse(x-r*0.05,y-r*0.1,r*0.01, r*0.02);
  ellipse(x+r*0.15,y-r*0.1,r*0.01, r*0.02);
  delay(1);//Use these parameters to create your graphics
}

Step 3

float[] x=new float [100];
float[] y=new float [100];
float[] r=new float [100];

void setup(){
size(800,800);
background(255);

for(int i = 0; i < 100; i = i+1) {
 x[i]=random(width);
 y[i]=random(height);
 r[i]=random(255);
  colorMode(HSB);
}
}

void draw() {
  for(int i = 0; i < 100; i++) {
    display(x[i],y[i],color(round(random(255)),175,255),r[i]);
} 
}

void display(float x, float y, color c,float r) {
  fill(c);
  stroke(0);
  strokeWeight(5);
  rect(x,y,r,r);
  arc(x, y, r*0.6, r*0.6, 0, PI-QUARTER_PI);
  stroke (0);
  strokeWeight(5);
  rect(x+r*0.1,y-r*0.2,r*0.1, r*0.2);
  rect(x-r*0.1,y-r*0.2,r*0.1, r*0.2);
  ellipse(x-r*0.05,y-r*0.1,r*0.01, r*0.02);
  ellipse(x+r*0.15,y-r*0.1,r*0.01, r*0.02);//Use these parameters to create your graphics
}

step 4

Based on step3, I added these two lines under “void dispay(){”

  x=x+random(-2,2);
  y=y+random(-2,2);

FINAL PROJECT PROPOSAL–Ketong Chen grouping with Tya Wang

The epic of us

  This will be a game involves two people to throw dice on Processing to obtain their weapon to attack others. The weapon will be fictitious and both players will have a blood stripe to show their states using Arduino. Also, in the process of the game, the player will also get objects to protect himself from the attack of others. Players need to try to kill each other to win the game.

  The game seems to be simple but confused people about the purpose of the game. Actually, we want to make people reflect on the wars between countries for their own benefits and also the fight between people for their own interests. We need to collaborate and share resources instead of fight to occupy all the resources. The weapon players get will be more and more powerful which represents how does the development of the technology increase the collapsing force of the weapon such as the atomic bomb. And players’ ability to protect themselves will relatively increase but when one of the players choose to use the most powerful weapon they will both die. This represents if we human beings do not stop fighting with each other, we will finally go astray

See from inside

  This is a game involves two players who both draw one of them by choosing the image and show it in processing or to directly draw each other. With the help of Arduino, we can tell the player who draws himself or herself to adjust the part of his or her face which he dissatisfied with and allow the other people to judge.

  This aims to show that people now are affected by the mainstream of beauty and are always dissatisfied with their outlook. But through this, it allows people to realize that not only the appearance decides one’s beauty, other people can feel the inside of you which is more than the only see from the appearance.

Revolution

This is a game that only allows people to draw things using straight lines using processing and it is shown using Arduino to make the other people guess what it is. It is hard to explain meanings using straight lines and we want to show the difficulty when using the machines to communicate and the misunderstanding causes by it. We want people to think about how to balance the use of machines and avoid being controlled by them.

Final Project Proposal By Ryan

Everything I have come up with is inspired by several following youtube videos

I see the potential and the charm that processing can achieve, I can make changing patterns based on algorithms which is very amazing. Geometry itself is already attracting for me, when it is combined and synchronized with music, it becomes even more amazing. And all of my idea are related to the sound and patterns. Also I have found library in processing used for sound visualization called Beads and Minim which are very useful for me.

Synthesizer

As what the title has revealed, this project is going to make a synthesizer based on processing and arduino. As what I have showed in the previous post

From 3:30 in this video is about a MIDI controller assembled by three keyboards which looks very interesting and inspiring. So this project is more based on touch, the processing part is just for supplement. I am thinking about using cupborads and cans to be the frame of a keyboard and the keys, also using plastic bags as pedals. The challenge is obvious, to arrange a huge amount of cans as keys to be different keys and make these sensitive, also the way of interaction is also a problem, am I going to tap them or hit them also needs to be decided. Also I have seen videos about musical instruments built on cans and the players just pat on these cans to make tunes. I need think of new ways of interaction and the way these keys are arranged to make interaction more interesting. The projet is for those who enjoys new ways of playing music, also the impact is going to be maybe adding a new way of playing music.

I have also find the conference called NIME, AKA New Interfaces for Musical Expression, very inspiring, there are many musicians in it discovering many new ways of interfaces. Following is their official website.

Compound sound visualizer

—— Fireworm Symphony  

This idea is very interesting and I really want to realize it, I was amazed by the music video called CYMATICS made by Nigel Stanford several years ago, you can find the video in the following link.

And also his personal website.

All of his works are very amazing, and this one which is related to the science of sound is one of most inspiring for me, and I really want to redo want he have done in the video to play with the resonance and sound waves. And I have done many researches on how to play with sound waves, and I find out three ways to do, Chaldni plate, lazer beam and water.

https://www.youtube.com/watch?v=AlSip26f0vA

Chaldni Patterns

For all of these visualizers need amplifier to make sound waves and effect on the meduim, sand, water and light.

For the Chaldni Plate, I need a plain board that is connected to an amplifier to let it vibrate the plate, and I spread the sand on it at a minimum amount to make the pattern clear. The pattern will change based on the sound frequency and the changes are very obvious, the most important part for this visualizer is to make sure the balance of everything. 

For the lazer visualizer, I am going to use reflection to visualize the sound, so there is a glass attached to the amplifier to be vibrated, then the lazer will be shone on it to be reflected to a screen or wall or the water visualizer that I will mention later, the reflection of the lazer will show how the sound changes based on the frequencies. 

For the water visualizer, I need a plate that can hold an enough amount of water while the water will not spill out when it vibrates with the amplifier. This visualizer will only work at a low frequency as if the frequency is too high, the water will be easily vibrated out of the plate to make a mess, so this visualizer will only be representing the bass.

I will simulate the motion of fireworm using processing and is controlled by gyroscope to trigger the strings on the screens to make certain frequency to trigger the amplifiers. The sand reminds people of the river bank with sand, while the water reminds ponds and rivers, the razer reminds the nightglow, combining everything to form a night view with fireworms.

All these three visualizers will be seperate to make sure they will not influence each other. The interaction part will be by lifting the hand or other gestures to control the sound frequencies and also will control which visualizer is on or off to make a combination of different visualizers. Also the processing will also become a visualizer of sound. So this is why the project is called a compound sound visualizer.  This will be an amazing experience to play with sound, to see sound in different forms at the same time will be interesting for everyone.

Stardust

This project is about motion capture by using processing, I find the tutorial about video capture very interesting and want to extend interaction based on it.

So I can recognize myself and the objects, what I am going to do is to make two controllers on hand to represent that theses are my hands and they will be two centers in the processing. These two controllers will also have buttons to have more functions, what I am willing to do now is to make a particle system and we can play with the particles by using the joystick. We can wipe on the scream, also we can use our hands as centers to absorb the particles around. And the particles will be colorful just like stardusts, and I will try to make these stardusts interact with sound, so we can import music as background and the color of the dust will change according to the music. I consider this project as an experience, kind of like virtual reality that feels like being in another world. I will try to make this as an immersive experience.

Recitation 7: Functions and Arrays

Step 1:

float x = 0;
float y = 0;
float c = 0;
float a = 0; 
float b = 0; 
void setup() {
  size(800, 800);
  background(188, 245, 244);
}

void draw(){

   pattern(400,400,247,236,17);

}
void pattern(float x , float y, float a , float b , float c ){
  
  stroke(255);
  strokeWeight(4);
  fill (a,b,c);
  triangle(x, y, x+100, y, x+50, y-100);

  stroke(255);
  strokeWeight(4);
  line(x, y, x+20, y+20);

  stroke(255);
  strokeWeight(4);
  line(x+50, y-100, x+70, y-80);

  stroke(255);
  strokeWeight(4);
  fill (a,b,c+100);
  triangle(x+20, y+20, x+120, y, x+70, y-80);
}
  

Abstract pattern unit

Question 1:

In your own words, please explain the difference between having your for loop from Step 2 in setup() as opposed to in draw().

Answer:

When the for loop is in setup(), it’s contents will repeat a limited amount of times- only as long as certain conditions are met. If it is placed in draw(), it can go on indefinitely.

Question 2:

What is the benefit of using arrays?  How might you use arrays in a potential project?

Answer:

Arrays allow objects in code to be described efficiently. We can use Arrays in Processing to construct shapes, for example

I was only able to complete the first step during recitation. I will attempt the remaining steps on my own time.