mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Follow 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
* Follow 1
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* A line segment is pushed and pulled by the cursor.
|
||||
*/
|
||||
@@ -12,7 +12,6 @@ float segLength = 50;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(255, 100);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Follow 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
* Follow 2
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* A two-segmented arm follows the cursor position. The relative
|
||||
* angle between the segments is calculated with atan2() and the
|
||||
@@ -13,7 +13,6 @@ float segLength = 50;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(255, 100);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Follow 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com).
|
||||
* Follow 3
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* A segmented line follows the mouse. The relative angle from
|
||||
* each segment to the next is calculated with atan2() and the
|
||||
@@ -13,7 +13,6 @@ float segLength = 18;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(9);
|
||||
stroke(255, 100);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Reach 1.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
* Reach 1
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
@@ -12,7 +12,6 @@ float x, y, x2, y2;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(255, 100);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Reach 2.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
* Reach 2
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* The arm follows the position of the mouse by
|
||||
* calculating the angles with atan2().
|
||||
@@ -15,7 +15,6 @@ float targetX, targetY;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(255, 100);
|
||||
x[x.length-1] = width/2; // Set base x-coordinate
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Reach 3.
|
||||
* Based on code from Keith Peters (www.bit-101.com)
|
||||
* Reach 3
|
||||
* based on code from Keith Peters.
|
||||
*
|
||||
* The arm follows the position of the ball by
|
||||
* calculating the angles with atan2().
|
||||
@@ -20,7 +20,6 @@ int ballYDirection = -1;
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
smooth();
|
||||
strokeWeight(20.0);
|
||||
stroke(255, 100);
|
||||
noFill();
|
||||
|
||||
@@ -5,16 +5,20 @@
|
||||
* Sometimes, it can be tickled off the screen.
|
||||
*/
|
||||
|
||||
// The next line is needed if running in JavaScript Mode with Processing.js
|
||||
/* @pjs font="Georgia.ttf"; */
|
||||
|
||||
String message = "tickle";
|
||||
PFont f;
|
||||
float x, y; // X and Y coordinates of text
|
||||
float hr, vr; // horizontal and vertical radius of the text
|
||||
|
||||
void setup() {
|
||||
size(640, 360);
|
||||
f = createFont("Courier New", 36);
|
||||
textFont(f);
|
||||
|
||||
// Create the font
|
||||
textFont(createFont("Georgia", 36));
|
||||
textAlign(CENTER, CENTER);
|
||||
|
||||
hr = textWidth(message) / 2;
|
||||
vr = (textAscent() + textDescent()) / 2;
|
||||
noStroke();
|
||||
@@ -23,16 +27,17 @@ void setup() {
|
||||
}
|
||||
|
||||
void draw() {
|
||||
// instead of clearing the background, fade it by drawing
|
||||
// Instead of clearing the background, fade it by drawing
|
||||
// a semi-transparent rectangle on top
|
||||
fill(204, 120);
|
||||
rect(0, 0, width, height);
|
||||
fill(0);
|
||||
|
||||
// If the cursor is over the text, change the position
|
||||
if (abs(mouseX - x) < hr &&
|
||||
abs(mouseY - y) < vr) {
|
||||
x += random(-5, 5);
|
||||
y += random(-5, 5);
|
||||
}
|
||||
fill(0);
|
||||
text("tickle", x, y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user