## Notes from Wednesday 9/17

Today we talked about persistent data: variables which are modified gradually from frame to frame.

Drunk Walk: a little insect that flits around.

```float ballx = 150.0; float bally = 150.0;   void setup(){ size(300,300); smooth(); }   void draw(){ background(255,200,200); strokeWeight(5); point(ballx,bally);   float rx = random(-3,3); float ry = random(-3,3); ballx = ballx + rx; bally = bally + ry; }```

Zeno’s motion paradox: smooth motion up to the cursor!

```float mx = 0; // DECLARE float my = 0;   void setup(){ size(400,400); } void draw(){ background(255,200,200);   float A = 0.90; float B = 1.0-A; mx = A*mx + B*mouseX; my = A*my + B*mouseY; ellipse(mx,my, 40,40); }```

Incrementation and decrementation with a “crement”, based on mouse clicks:

```int clickCounter = 0; // how many times we have clicked int crement = 1; // which direction we are counting: up (1) or down (-1)   void setup(){ size(300,300); }   void draw(){ background(255); fill(255,0,0); int r = clickCounter * 10; ellipse(width/2,height/2, r,r); }   void mousePressed(){ clickCounter += crement; if ((clickCounter >= 8) || (clickCounter <= 0)){ crement = (0 - crement); // flip the crement! } println(clickCounter + " " + crement); }```

## Notes from Monday 9/15

Solution to one of the homeworks:

```void setup(){ size(300,100); smooth(); noStroke(); }   void draw(){ background(230); int spacing = 20; int offset = 50;   for (int i=0; i<10; i=i+1){ int x = i*spacing + offset;   int r = 0; if (i%3 ==0){ r = 255; } fill(r,0,0); ellipse(x,50, 15,15); } }```

Test keys and convert to lowercase:

```void setup(){ size(300,300); }   void draw(){ background(230); char c = key;   if ((c >= 'A') && (c <= 'Z')){ println("CAPITAL"); c = (char)(c+32); ellipse(150,150,100,100); } else if ((c >= 'a') && (c <= 'z')){ println("lowercase"); rect(100,100,100,100); } else { println("sumthin else ... ? "); } println(key + " " + c); }```

Switch statement:

```  void setup(){   } void draw(){ char myChar = key;   switch(myChar){ case 'a': println ("apple"); break; case 'b': println ("bear"); break;   case 'c': println ("cat"); case 'd': case 'e': println("c,d, or e"); break;   default: println ("default"); } println("--------------"); }```