Skip to content

Commit

Permalink
added
Browse files Browse the repository at this point in the history
  • Loading branch information
ynaoto committed Jul 26, 2014
1 parent 00aa51c commit 9f48001
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 0 deletions.
17 changes: 17 additions & 0 deletions common/LineAndBall_006/LineAndBall_006.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
float xh = 70;
float yh = 70;
float xo = 255;
float yo = 55;

void setup() {
size(300, 300);
}

void draw() {
background(255, 0, 0);
line(xh, yh, xo, yo);
float xf = xh + (xo - xh)/5;
float yf = yh + (yo - yh)/5;
ellipse(xf, yf, 10, 10);
}

2 changes: 2 additions & 0 deletions common/LineAndBall_006/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
17 changes: 17 additions & 0 deletions common/LineAndBall_007/LineAndBall_007.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
float xh = 70;
float yh = 70;
float xo = 255;
float yo = 55;

void setup() {
size(300, 300);
}

void draw() {
background(255, 0, 0);
line(xh, yh, xo, yo);
float xf = xh + 0.2*(xo - xh);
float yf = yh + 0.2*(yo - yh);
ellipse(xf, yf, 10, 10);
}

2 changes: 2 additions & 0 deletions common/LineAndBall_007/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
18 changes: 18 additions & 0 deletions common/LineAndBall_008/LineAndBall_008.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
float xh = 70;
float yh = 70;
float xo = 255;
float yo = 55;

void setup() {
size(300, 300);
}

void draw() {
background(255, 0, 0);
line(xh, yh, xo, yo);
float a = map(mouseX, 0, width, 0, 1);
float xf = xh + a*(xo - xh);
float yf = yh + a*(yo - yh);
ellipse(xf, yf, 10, 10);
}

2 changes: 2 additions & 0 deletions common/LineAndBall_008/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
19 changes: 19 additions & 0 deletions common/LineAndBall_008a/LineAndBall_008a.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
float xh = 70;
float yh = 70;
float xo = 255;
float yo = 55;

void setup() {
size(300, 300);
}

void draw() {
background(255, 0, 0);
line(xh, yh, xo, yo);
float a = map(mouseX, 0, width, 0, 1);
float r = map(mouseY, 0, height, 1, 50);
float xf = xh + a*(xo - xh);
float yf = yh + a*(yo - yh);
ellipse(xf, yf, r, r);
}

2 changes: 2 additions & 0 deletions common/LineAndBall_008a/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java
55 changes: 55 additions & 0 deletions common/LineAndBall_009/LineAndBall_009.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class Drop {
float x, y, r;
float vy;
Drop(float x, float y, float r) {
this.x = x;
this.y = y;
this.r = r;
vy = 0;
}
void update() {
y += vy;
vy += 0.2;
}
void draw() {
ellipse(x, y, r, r);
}
}

ArrayList<Drop> drops;

float xh = 70;
float yh = 70;
float xo = 255;
float yo = 55;

void setup() {
size(300, 300);
drops = new ArrayList<Drop>();
}

void draw() {
background(255, 0, 0);
// fill(255, 0, 0, 10);
// rect(0, 0, width, height);
// fill(255);
line(xh, yh, xo, yo);
float a = map(mouseX, 0, width, 0, 1);
float r = map(mouseY, 0, height, 1, 50);
float xf = xh + a*(xo - xh);
float yf = yh + a*(yo - yh);
ellipse(xf, yf, r, r);

Drop drop = new Drop(xf, yf, r);
drops.add(drop);
int n = drops.size();
for (int i = n-1; 0 <= i; i--) {
Drop d = drops.get(i);
d.update();
d.draw();
if (height < d.y) {
drops.remove(i);
}
}
}

2 changes: 2 additions & 0 deletions common/LineAndBall_009/sketch.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mode.id=processing.mode.java.JavaMode
mode=Java

0 comments on commit 9f48001

Please sign in to comment.