More Related Content
Similar to Kwp2 100121 (14)
Kwp2 100121
- 11. //
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;
}
- 14. //
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));
}
- 16. //
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;
}
- 19. //
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;
}
- 20. 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;
}
- 22. //
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);
- 23. 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++){
- 24. void mouseReleased()
{
pressed = false;
for(int i=0; i<NUM; i++){
targetX[i] = random(width);
targetY[i] = random(height);
}
}