Kwp2 100121

658 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
658
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Kwp2 100121

    1. 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. 2. void mousePressed() { pressed = true; } void mouseReleased() { pressed = false; }
    3. 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. 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. 5. void mousePressed(){ pressed = true; } void mouseReleased(){ pressed = false; }
    6. 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. 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. 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. 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. 10. void mouseReleased() { pressed = false; for(int i=0; i<NUM; i++){ targetX[i] = random(width); targetY[i] = random(height); } }

    ×