• Like
Kwp2 100121
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

Kwp2 100121

  • 1,084 views
Published

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
1,084
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
9
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. // boolean pressed = false; int count; void setup() { size(400,400); noStroke(); colorMode(HSB,360,100,100,100); background(0); } void draw() { if(pressed){ fill(0,0,0,0.4); rect(0,0,width,height); fill(count%360,80,80,20); ellipse(mouseX, mouseY, 40, 40); ellipse(width-mouseX, mouseY, 40, 40); ellipse(mouseX, height-mouseY, 40, 40); ellipse(width-mouseX, height-mouseY, 40, 40); } count = count + 1; }
  • 2. void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; }
  • 3. // void setup() { size(400, 400); noStroke(); smooth(); } void draw() { background(0,0,0); fill(31,127,255,200); ellipse(mouseX, height/2, mouseY/3, mouseY/3); ellipse(width-mouseX,height/2,((height-mouseY)/3),((height-mouseY)/3)); }
  • 4. // boolean pressed = false; int count; void setup() { size(400, 400); noStroke(); colorMode(HSB,360,100,100,100); background(0); rectMode(CENTER); } void draw() { if(pressed){ fill(count%360,100,100,5); rect(mouseX, height/2, random(10,20), height); } count = count+1; }
  • 5. void mousePressed(){ pressed = true; } void mouseReleased(){ pressed = false; }
  • 6. // float x, y; float targetX, targetY; float easing = 0.05; boolean pressed = false; void setup() { size(400, 400); smooth(); noStroke(); background(0,0,0); } void draw() { fill(0,0,0,10); rect(0,0,width,height); if(pressed){ targetX = mouseX; targetY = mouseY; }
  • 7. float dx = targetX - x; x += dx * easing; float dy = targetY - y; y += dy * easing; fill(31,127,255); ellipse(x, y, 33, 33); } void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; }
  • 8. // int NUM = 400; float[] x = new float[NUM]; float[] y = new float[NUM]; float[] targetX = new float[NUM]; float[] targetY = new float[NUM]; float easing = 0.05; boolean pressed = false; void setup() { size(400, 400); smooth(); noStroke(); background(0,0,0); for(int i=0; i<NUM; i++){ x[i] = targetX[i] = random(width); y[i] = targetY[i] = random(height); } } void draw() { fill(0,0,0,10);
  • 9. for(int i=0; i<NUM; i++){ if(pressed){ targetX[i] = mouseX; targetY[i] = mouseY; } float dx = targetX[i] - x[i]; x[i] += dx * easing; float dy = targetY[i] - y[i]; y[i] += dy * easing; fill(31,127,255,40); ellipse(x[i], y[i], 20, 20); } } void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; for(int i=0; i<NUM; i++){
  • 10. void mouseReleased() { pressed = false; for(int i=0; i<NUM; i++){ targetX[i] = random(width); targetY[i] = random(height); } }