removing applet folders from svn
@@ -1,59 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Follow1 extends PApplet {
|
||||
|
||||
/**
|
||||
* Follow 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A line segment is pushed and pulled by the cursor.
|
||||
*/
|
||||
|
||||
float x = 100;
|
||||
float y = 100;
|
||||
float angle1 = 0.0f;
|
||||
float segLength = 50;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0f);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
|
||||
float dx = mouseX - x;
|
||||
float dy = mouseY - y;
|
||||
angle1 = atan2(dy, dx);
|
||||
x = mouseX - (cos(angle1) * segLength);
|
||||
y = mouseY - (sin(angle1) * segLength);
|
||||
|
||||
segment(x, y, angle1);
|
||||
ellipse(x, y, 20, 20);
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Follow1" });
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* Follow 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A line segment is pushed and pulled by the cursor.
|
||||
*/
|
||||
|
||||
float x = 100;
|
||||
float y = 100;
|
||||
float angle1 = 0.0;
|
||||
float segLength = 50;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
|
||||
float dx = mouseX - x;
|
||||
float dy = mouseY - y;
|
||||
angle1 = atan2(dy, dx);
|
||||
x = mouseX - (cos(angle1) * segLength);
|
||||
y = mouseY - (sin(angle1) * segLength);
|
||||
|
||||
segment(x, y, angle1);
|
||||
ellipse(x, y, 20, 20);
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,62 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Follow2 extends PApplet {
|
||||
|
||||
/**
|
||||
* Follow 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A two-segmented arm follows the cursor position. The relative
|
||||
* angle between the segments is calculated with atan2() and the
|
||||
* position calculated with sin() and cos().
|
||||
*/
|
||||
|
||||
float[] x = new float[2];
|
||||
float[] y = new float[2];
|
||||
float segLength = 50;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0f);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
dragSegment(0, mouseX, mouseY);
|
||||
dragSegment(1, x[0], y[0]);
|
||||
}
|
||||
|
||||
public void dragSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
float angle = atan2(dy, dx);
|
||||
x[i] = xin - cos(angle) * segLength;
|
||||
y[i] = yin - sin(angle) * segLength;
|
||||
segment(x[i], y[i], angle);
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Follow2" });
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/**
|
||||
* Follow 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A two-segmented arm follows the cursor position. The relative
|
||||
* angle between the segments is calculated with atan2() and the
|
||||
* position calculated with sin() and cos().
|
||||
*/
|
||||
|
||||
float[] x = new float[2];
|
||||
float[] y = new float[2];
|
||||
float segLength = 50;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
dragSegment(0, mouseX, mouseY);
|
||||
dragSegment(1, x[0], y[0]);
|
||||
}
|
||||
|
||||
void dragSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
float angle = atan2(dy, dx);
|
||||
x[i] = xin - cos(angle) * segLength;
|
||||
y[i] = yin - sin(angle) * segLength;
|
||||
segment(x[i], y[i], angle);
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,64 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Follow3 extends PApplet {
|
||||
|
||||
/**
|
||||
* Follow 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A segmented line follows the mouse. The relative angle from
|
||||
* each segment to the next is calculated with atan2() and the
|
||||
* position of the next is calculated with sin() and cos().
|
||||
*/
|
||||
|
||||
float[] x = new float[20];
|
||||
float[] y = new float[20];
|
||||
float segLength = 9;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(5);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
dragSegment(0, mouseX, mouseY);
|
||||
for(int i=0; i<x.length-1; i++) {
|
||||
dragSegment(i+1, x[i], y[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void dragSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
float angle = atan2(dy, dx);
|
||||
x[i] = xin - cos(angle) * segLength;
|
||||
y[i] = yin - sin(angle) * segLength;
|
||||
segment(x[i], y[i], angle);
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Follow3" });
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* Follow 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
*
|
||||
* A segmented line follows the mouse. The relative angle from
|
||||
* each segment to the next is calculated with atan2() and the
|
||||
* position of the next is calculated with sin() and cos().
|
||||
*/
|
||||
|
||||
float[] x = new float[20];
|
||||
float[] y = new float[20];
|
||||
float segLength = 9;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(5);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
dragSegment(0, mouseX, mouseY);
|
||||
for(int i=0; i<x.length-1; i++) {
|
||||
dragSegment(i+1, x[i], y[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void dragSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
float angle = atan2(dy, dx);
|
||||
x[i] = xin - cos(angle) * segLength;
|
||||
y[i] = yin - sin(angle) * segLength;
|
||||
segment(x[i], y[i], angle);
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,69 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Reach1 extends PApplet {
|
||||
|
||||
/**
|
||||
* Reach 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
|
||||
float x = 100;
|
||||
float y = 100;
|
||||
float x2 = 100;
|
||||
float y2 = 100;
|
||||
float segLength = 30;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0f);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
|
||||
float dx = mouseX - x;
|
||||
float dy = mouseY - y;
|
||||
float angle1 = atan2(dy, dx);
|
||||
|
||||
float tx = mouseX - cos(angle1) * segLength;
|
||||
float ty = mouseY - sin(angle1) * segLength;
|
||||
dx = tx - x2;
|
||||
dy = ty - y2;
|
||||
float angle2 = atan2(dy, dx);
|
||||
x = x2 + cos(angle2) * segLength;
|
||||
y = y2 + sin(angle2) * segLength;
|
||||
|
||||
segment(x, y, angle1);
|
||||
segment(x2, y2, angle2);
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Reach1" });
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Reach 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
|
||||
float x = 100;
|
||||
float y = 100;
|
||||
float x2 = 100;
|
||||
float y2 = 100;
|
||||
float segLength = 30;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(0, 100);
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
|
||||
float dx = mouseX - x;
|
||||
float dy = mouseY - y;
|
||||
float angle1 = atan2(dy, dx);
|
||||
|
||||
float tx = mouseX - cos(angle1) * segLength;
|
||||
float ty = mouseY - sin(angle1) * segLength;
|
||||
dx = tx - x2;
|
||||
dy = ty - y2;
|
||||
float angle2 = atan2(dy, dx);
|
||||
x = x2 + cos(angle2) * segLength;
|
||||
y = y2 + sin(angle2) * segLength;
|
||||
|
||||
segment(x, y, angle1);
|
||||
segment(x2, y2, angle2);
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a) {
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,80 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Reach2 extends PApplet {
|
||||
|
||||
/**
|
||||
* Reach 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
int numSegments = 10;
|
||||
float[] x = new float[numSegments];
|
||||
float[] y = new float[numSegments];
|
||||
float[] angle = new float[numSegments];
|
||||
float segLength = 20;
|
||||
float targetX, targetY;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0f);
|
||||
stroke(0, 100);
|
||||
x[x.length-1] = 0; // Set base x-coordinate
|
||||
y[x.length-1] = height; // Set base y-coordinate
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
|
||||
reachSegment(0, mouseX, mouseY);
|
||||
for(int i=1; i<numSegments; i++) {
|
||||
reachSegment(i, targetX, targetY);
|
||||
}
|
||||
for(int i=x.length-1; i>=1; i--) {
|
||||
positionSegment(i, i-1);
|
||||
}
|
||||
for(int i=0; i<x.length; i++) {
|
||||
segment(x[i], y[i], angle[i], (i+1)*2);
|
||||
}
|
||||
}
|
||||
|
||||
public void positionSegment(int a, int b) {
|
||||
x[b] = x[a] + cos(angle[a]) * segLength;
|
||||
y[b] = y[a] + sin(angle[a]) * segLength;
|
||||
}
|
||||
|
||||
public void reachSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
angle[i] = atan2(dy, dx);
|
||||
targetX = xin - cos(angle[i]) * segLength;
|
||||
targetY = yin - sin(angle[i]) * segLength;
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a, float sw) {
|
||||
strokeWeight(sw);
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Reach2" });
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Reach 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
int numSegments = 10;
|
||||
float[] x = new float[numSegments];
|
||||
float[] y = new float[numSegments];
|
||||
float[] angle = new float[numSegments];
|
||||
float segLength = 20;
|
||||
float targetX, targetY;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(0, 100);
|
||||
x[x.length-1] = 0; // Set base x-coordinate
|
||||
y[x.length-1] = height; // Set base y-coordinate
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
|
||||
reachSegment(0, mouseX, mouseY);
|
||||
for(int i=1; i<numSegments; i++) {
|
||||
reachSegment(i, targetX, targetY);
|
||||
}
|
||||
for(int i=x.length-1; i>=1; i--) {
|
||||
positionSegment(i, i-1);
|
||||
}
|
||||
for(int i=0; i<x.length; i++) {
|
||||
segment(x[i], y[i], angle[i], (i+1)*2);
|
||||
}
|
||||
}
|
||||
|
||||
void positionSegment(int a, int b) {
|
||||
x[b] = x[a] + cos(angle[a]) * segLength;
|
||||
y[b] = y[a] + sin(angle[a]) * segLength;
|
||||
}
|
||||
|
||||
void reachSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
angle[i] = atan2(dy, dx);
|
||||
targetX = xin - cos(angle[i]) * segLength;
|
||||
targetY = yin - sin(angle[i]) * segLength;
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a, float sw) {
|
||||
strokeWeight(sw);
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,97 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Reach3 extends PApplet {
|
||||
|
||||
/**
|
||||
* Reach 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the ball by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
int numSegments = 6;
|
||||
float[] x = new float[numSegments];
|
||||
float[] y = new float[numSegments];
|
||||
float[] angle = new float[numSegments];
|
||||
float segLength = 15;
|
||||
float targetX, targetY;
|
||||
|
||||
float ballX = 50;
|
||||
float ballY = 50;
|
||||
int ballXDirection = 1;
|
||||
int ballYDirection = -1;
|
||||
|
||||
public void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0f);
|
||||
stroke(0, 100);
|
||||
noFill();
|
||||
x[x.length-1] = width/2; // Set base x-coordinate
|
||||
y[x.length-1] = height; // Set base y-coordinate
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
background(226);
|
||||
|
||||
strokeWeight(20);
|
||||
ballX = ballX + 1.0f * ballXDirection;
|
||||
ballY = ballY + 0.8f * ballYDirection;
|
||||
if(ballX > width-25 || ballX < 25) {
|
||||
ballXDirection *= -1;
|
||||
}
|
||||
if(ballY > height-25 || ballY < 25) {
|
||||
ballYDirection *= -1;
|
||||
}
|
||||
ellipse(ballX, ballY, 30, 30);
|
||||
|
||||
reachSegment(0, ballX, ballY);
|
||||
for(int i=1; i<numSegments; i++) {
|
||||
reachSegment(i, targetX, targetY);
|
||||
}
|
||||
for(int i=x.length-1; i>=1; i--) {
|
||||
positionSegment(i, i-1);
|
||||
}
|
||||
for(int i=0; i<x.length; i++) {
|
||||
segment(x[i], y[i], angle[i], (i+1)*2);
|
||||
}
|
||||
}
|
||||
|
||||
public void positionSegment(int a, int b) {
|
||||
x[b] = x[a] + cos(angle[a]) * segLength;
|
||||
y[b] = y[a] + sin(angle[a]) * segLength;
|
||||
}
|
||||
|
||||
public void reachSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
angle[i] = atan2(dy, dx);
|
||||
targetX = xin - cos(angle[i]) * segLength;
|
||||
targetY = yin - sin(angle[i]) * segLength;
|
||||
}
|
||||
|
||||
public void segment(float x, float y, float a, float sw) {
|
||||
strokeWeight(sw);
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Reach3" });
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/**
|
||||
* Reach 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
*
|
||||
* The arm follows the position of the ball by
|
||||
* calculating the angles with atan2().
|
||||
*/
|
||||
|
||||
int numSegments = 6;
|
||||
float[] x = new float[numSegments];
|
||||
float[] y = new float[numSegments];
|
||||
float[] angle = new float[numSegments];
|
||||
float segLength = 15;
|
||||
float targetX, targetY;
|
||||
|
||||
float ballX = 50;
|
||||
float ballY = 50;
|
||||
int ballXDirection = 1;
|
||||
int ballYDirection = -1;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(0, 100);
|
||||
noFill();
|
||||
x[x.length-1] = width/2; // Set base x-coordinate
|
||||
y[x.length-1] = height; // Set base y-coordinate
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(226);
|
||||
|
||||
strokeWeight(20);
|
||||
ballX = ballX + 1.0 * ballXDirection;
|
||||
ballY = ballY + 0.8 * ballYDirection;
|
||||
if(ballX > width-25 || ballX < 25) {
|
||||
ballXDirection *= -1;
|
||||
}
|
||||
if(ballY > height-25 || ballY < 25) {
|
||||
ballYDirection *= -1;
|
||||
}
|
||||
ellipse(ballX, ballY, 30, 30);
|
||||
|
||||
reachSegment(0, ballX, ballY);
|
||||
for(int i=1; i<numSegments; i++) {
|
||||
reachSegment(i, targetX, targetY);
|
||||
}
|
||||
for(int i=x.length-1; i>=1; i--) {
|
||||
positionSegment(i, i-1);
|
||||
}
|
||||
for(int i=0; i<x.length; i++) {
|
||||
segment(x[i], y[i], angle[i], (i+1)*2);
|
||||
}
|
||||
}
|
||||
|
||||
void positionSegment(int a, int b) {
|
||||
x[b] = x[a] + cos(angle[a]) * segLength;
|
||||
y[b] = y[a] + sin(angle[a]) * segLength;
|
||||
}
|
||||
|
||||
void reachSegment(int i, float xin, float yin) {
|
||||
float dx = xin - x[i];
|
||||
float dy = yin - y[i];
|
||||
angle[i] = atan2(dy, dx);
|
||||
targetX = xin - cos(angle[i]) * segLength;
|
||||
targetY = yin - sin(angle[i]) * segLength;
|
||||
}
|
||||
|
||||
void segment(float x, float y, float a, float sw) {
|
||||
strokeWeight(sw);
|
||||
pushMatrix();
|
||||
translate(x, y);
|
||||
rotate(a);
|
||||
line(0, 0, segLength, 0);
|
||||
popMatrix();
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,52 +0,0 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Tickle extends PApplet {
|
||||
|
||||
/**
|
||||
* Tickle.
|
||||
*
|
||||
* The word "tickle" jitters when the cursor hovers over.
|
||||
* Sometimes, it can be tickled off the screen.
|
||||
*/
|
||||
|
||||
PFont font;
|
||||
float x = 33; // X-coordinate of text
|
||||
float y = 60; // Y-coordinate of text
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
font = loadFont("AmericanTypewriter-24.vlw");
|
||||
textFont(font);
|
||||
noStroke();
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
fill(204, 120);
|
||||
rect(0, 0, width, height);
|
||||
fill(0);
|
||||
// If the cursor is over the text, change the position
|
||||
if ((mouseX >= x) && (mouseX <= x+55) &&
|
||||
(mouseY >= y-24) && (mouseY <= y)) {
|
||||
x += random(-5, 5);
|
||||
y += random(-5, 5);
|
||||
}
|
||||
text("tickle", x, y);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Tickle" });
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* Tickle.
|
||||
*
|
||||
* The word "tickle" jitters when the cursor hovers over.
|
||||
* Sometimes, it can be tickled off the screen.
|
||||
*/
|
||||
|
||||
PFont font;
|
||||
float x = 33; // X-coordinate of text
|
||||
float y = 60; // Y-coordinate of text
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200, 200);
|
||||
font = loadFont("AmericanTypewriter-24.vlw");
|
||||
textFont(font);
|
||||
noStroke();
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
fill(204, 120);
|
||||
rect(0, 0, width, height);
|
||||
fill(0);
|
||||
// If the cursor is over the text, change the position
|
||||
if ((mouseX >= x) && (mouseX <= x+55) &&
|
||||
(mouseY >= y-24) && (mouseY <= y)) {
|
||||
x += random(-5, 5);
|
||||
y += random(-5, 5);
|
||||
}
|
||||
text("tickle", x, y);
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.2 KiB |