User Tools

Site Tools


spcs:2015:day4

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
spcs:2015:day4 [2015/07/08 20:23]
ffpaladin
spcs:2015:day4 [2015/07/09 05:26]
ffpaladin
Line 17: Line 17:
     - Step 2: make it visual with rectangles     - Step 2: make it visual with rectangles
     - http://​visualgo.net/​sorting.html     - http://​visualgo.net/​sorting.html
-  - **Processing: ​Physics** - Create objects that represent physics. You can make it more realistic, like with gravity if you are able. +  - **Processing: ​Seurat Painting** - How do we make a Seurat Painting animation in Processing 
-  - **Processing: Simulation** - Pick a simulation that will teach me something. +    Step 1: Make an animation 
-  **Processing: Make a Game** - To make a game, give it interactions and a winning condition (Ludus and Paida). +    Step 2: Make it so that the user can change the size of the circle
-  **Processing (Bonus)Interaction** - Make any of the above MORE interactive.+
   - **Github** - You can store your processing projects directly there and run them with Processing.js - Read: http://​processingjs.org/​articles/​jsQuickStart.html (Similar to yesterday)   - **Github** - You can store your processing projects directly there and run them with Processing.js - Read: http://​processingjs.org/​articles/​jsQuickStart.html (Similar to yesterday)
  
Line 35: Line 34:
  
 <code java> <code java>
 +
 +// Selection Sort
  
  
Line 85: Line 86:
   - Jeff, Samuel   - Jeff, Samuel
   - Chris, Frank   - Chris, Frank
 +
 +
 +<code java>
 +
 +
 +// Credit: RadioTech@Github
 +// Visual Sort
 +
 +int i = 0, j = 0;
 +int tempcheesestick;​
 +int sticks = 40;
 +
 +int[] cheesesticks = new int [sticks];
 +int[] oldsticks = new int [sticks];
 +
 +void setup() {
 +  ​
 +  ​
 +  size(500,​400);​
 +  for(int fi = 0; fi < sticks; fi++){
 +    cheesesticks[fi] = round(random(500));​
 +    oldsticks[fi] = cheesesticks[fi];​
 +  }
 +}
 +
 +void draw() {
 +  ​
 +  ​
 +  if(j>​-1){
 +    ​
 +    ​
 +    if(i>​-1){
 +      if(cheesesticks[i]>​cheesesticks[i+1]){
 +        tempcheesestick = cheesesticks[i];  ​
 +        cheesesticks[i] = cheesesticks[i+1];​
 +        cheesesticks[i+1] = tempcheesestick;​
 +      }
 +      ​
 +      i++;
 +      if(i >= sticks-1){
 +         i = 0;
 +         j++;
 +      }
 +    }
 +    ​
 +    ​
 +    if(j >= sticks-1){
 +       j = -1; 
 +    }
 +    ​
 +  }
 +  ​
 +  rectMode(CENTER);​
 +  background(255);​
 +  for(int fi = 0; fi < sticks; fi++){
 +    if(cheesesticks[fi] == oldsticks[fi]){
 +       ​fill(255,​200,​0); ​
 +    } else {
 +       ​fill(255,​0,​0); ​
 +    }
 +    ​
 +    rect(cheesesticks[fi]/​2-1,​(400/​sticks)*fi+(400/​sticks)/​2,​cheesesticks[fi],​400/​sticks);​
 + 
 +    oldsticks[fi] = cheesesticks[fi];​
 +  }
 +  ​
 +</​code>​
 +
 +
 +</​code>​
 +
 +<code java>
 +
 +// Credit: Neel
 +
 +int[] cheesesticks = {200, 40, 170, 50, 70, 60, 80, 90, 190, 150, 100, 110, 120, 140, 180, 130, 20, 160, 30, 10};
 +
 +int i = -1;
 +int j = 0;
 +int min;
 +
 +void setup() {
 +  size (250, 250);
 +}
 +
 +void draw() {
 +  ​
 +  background(200);​
 +  ​
 +  // only runs after j reaches 20  ​
 +  if ((j == 20) && (i < 19)) {
 + 
 +     i++;
 +     ​j=i+1;​
 +     min = cheesesticks[i];​
 +  }
 + 
 +  // runs as long as j is less than 20
 +  if (j < 20) {
 + 
 +    if (cheesesticks[j] < min){
 +      min = cheesesticks[j];​
 +      //swap
 +      int temp = cheesesticks[i];​
 +      cheesesticks[i] = cheesesticks[j];​
 +      cheesesticks[j] = temp;
 +    }
 +    j++;
 +  }
 +  ​
 +  fill(#​EA5353);​
 +
 +for (int i=0; i<20; i++)
 +  {
 +    rect(0, i*10,​cheesesticks[i],​ 5);
 +  }
 +
 +
 +
 +</​code>​
  
/soe/sherol/.html/teaching/data/pages/spcs/2015/day4.txt · Last modified: 2015/07/09 05:26 by ffpaladin