FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Examples updates to 640 x 360 pixels · ddf/processing@0dd6355 · GitHub

Repository navigation

Commit 0dd6355

Browse files
committed
Examples updates to 640 x 360 pixels
1 parent 06ea9e5 commit 0dd6355

52 files changed

Lines changed: 292 additions & 299 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎java/examples/Basics/Form/Bezier/Bezier.pde‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
* the last point. The middle parameters set the control points
77
* that define the shape of the curve.
88
*/
9-
10-
size(640, 360);
11-
background(0);
12-
stroke(255);
13-
noFill();
14-
smooth();
159

16-
for(int i = 0; i < 200; i += 20) {
17-
bezier(180-(i/2.0), 40+i, 410, 20, 440, 300, 240-(i/16.0), 300+(i/8.0));
10+
void setup() {
11+
size(640, 360);
12+
stroke(255);
13+
noFill();
14+
smooth();
1815
}
16+
17+
void draw() {
18+
background(0);
19+
for (int i = 0; i < 200; i += 20) {
20+
bezier(mouseX-(i/2.0), 40+i, 410, 20, 440, 300, 240-(i/16.0), 300+(i/8.0));
21+
}
22+
}
23+

‎java/examples/Basics/Form/TriangleStrip/TriangleStrip.pde‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ int x;
1313
int y;
1414
float outerRad;
1515
float innerRad;
16-
float px = 0;
17-
float py = 0;
18-
float angle = 0;
19-
float pts = 36;
20-
float rot = 360.0/pts;
2116

2217
void setup() {
2318
size(640, 360);
@@ -30,10 +25,16 @@ void setup() {
3025
}
3126

3227
void draw() {
28+
background(204);
29+
30+
int pts = int(map(mouseX, 0, width, 6, 60));
31+
float rot = 180.0/pts;
32+
float angle = 0;
33+
3334
beginShape(TRIANGLE_STRIP);
34-
for (int i = 0; i < pts; i++) {
35-
px = x + cos(radians(angle)) * outerRad;
36-
py = y + sin(radians(angle)) * outerRad;
35+
for (int i = 0; i <= pts; i++) {
36+
float px = x + cos(radians(angle)) * outerRad;
37+
float py = y + sin(radians(angle)) * outerRad;
3738
angle += rot;
3839
vertex(px, py);
3940
px = x + cos(radians(angle)) * innerRad;

‎java/examples/Basics/Input/Constrain/Constrain.pde‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*
44
* Move the mouse across the screen to move the circle.
55
* The program constrains the circle to its box.
6-
*
7-
* Updated 27 February 2010 to handle changes in size().
86
*/
97

108
float mx;

‎java/examples/Basics/Input/KeyboardFunctions/KeyboardFunctions.pde‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void setup()
3030
background(numChars/2);
3131
// Set a gray value for each key
3232
for(int i=0; i<numChars; i++) {
33-
colors[i] = color(i, i, i);
33+
colors[i] = color(i);
3434
}
3535
}
3636

‎java/examples/Basics/Input/MouseFunctions/MouseFunctions.pde‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66

77
float bx;
88
float by;
9-
int bs = 75;
10-
boolean bover = false;
9+
int boxSize = 75;
10+
boolean overBox = false;
1111
boolean locked = false;
12-
float bdifx = 0.0;
13-
float bdify = 0.0;
14-
12+
float xOffset = 0.0;
13+
float yOffset = 0.0;
1514

1615
void setup()
1716
{
@@ -26,39 +25,39 @@ void draw()
2625
background(0);
2726

2827
// Test if the cursor is over the box
29-
if (mouseX > bx-bs && mouseX < bx+bs &&
30-
mouseY > by-bs && mouseY < by+bs) {
31-
bover = true;
28+
if (mouseX > bx-boxSize && mouseX < bx+boxSize &&
29+
mouseY > by-boxSize && mouseY < by+boxSize) {
30+
overBox = true;
3231
if(!locked) {
3332
stroke(255);
3433
fill(153);
3534
}
3635
} else {
3736
stroke(153);
3837
fill(153);
39-
bover = false;
38+
overBox = false;
4039
}
4140

4241
// Draw the box
43-
rect(bx, by, bs, bs);
42+
rect(bx, by, boxSize, boxSize);
4443
}
4544

4645
void mousePressed() {
47-
if(bover) {
46+
if(overBox) {
4847
locked = true;
4948
fill(255, 255, 255);
5049
} else {
5150
locked = false;
5251
}
53-
bdifx = mouseX-bx;
54-
bdify = mouseY-by;
52+
xOffset = mouseX-bx;
53+
yOffset = mouseY-by;
5554

5655
}
5756

5857
void mouseDragged() {
5958
if(locked) {
60-
bx = mouseX-bdifx;
61-
by = mouseY-bdify;
59+
bx = mouseX-xOffset;
60+
by = mouseY-yOffset;
6261
}
6362
}
6463

‎java/examples/Basics/Input/MousePress/MousePress.pde‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void setup() {
1313
}
1414

1515
void draw() {
16-
if(mousePressed) {
16+
if (mousePressed) {
1717
stroke(255);
1818
} else {
1919
stroke(0);

‎java/examples/Basics/Math/Arctangent/Arctangent.pde‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@
66
* to the cursor.
77
*/
88

9-
Eye e1, e2, e3, e4, e5;
9+
Eye e1, e2, e3;
1010

1111
void setup()
1212
{
13-
size(200, 200);
13+
size(640, 360);
1414
smooth();
1515
noStroke();
16-
e1 = new Eye( 50, 16, 80);
17-
e2 = new Eye( 64, 85, 40);
18-
e3 = new Eye( 90, 200, 120);
19-
e4 = new Eye(150, 44, 40);
20-
e5 = new Eye(175, 120, 80);
16+
e1 = new Eye( 190, 16, 120);
17+
e2 = new Eye( 164, 185, 80);
18+
e3 = new Eye( 390, 200, 220);
2119
}
2220

2321
void draw()
@@ -27,35 +25,31 @@ void draw()
2725
e1.update(mouseX, mouseY);
2826
e2.update(mouseX, mouseY);
2927
e3.update(mouseX, mouseY);
30-
e4.update(mouseX, mouseY);
31-
e5.update(mouseX, mouseY);
3228

3329
e1.display();
3430
e2.display();
3531
e3.display();
36-
e4.display();
37-
e5.display();
3832
}
3933

4034
class Eye
4135
{
42-
int ex, ey;
36+
int x, y;
4337
int size;
4438
float angle = 0.0;
4539

46-
Eye(int x, int y, int s) {
47-
ex = x;
48-
ey = y;
49-
size = s;
40+
Eye(int tx, int ty, int ts) {
41+
x = tx;
42+
y = ty;
43+
size = ts;
5044
}
5145

5246
void update(int mx, int my) {
53-
angle = atan2(my-ey, mx-ex);
47+
angle = atan2(my-y, mx-x);
5448
}
5549

5650
void display() {
5751
pushMatrix();
58-
translate(ex, ey);
52+
translate(x, y);
5953
fill(255);
6054
ellipse(0, 0, size, size);
6155
rotate(angle);

‎java/examples/Basics/Math/Distance1D/Distance1D.pde‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
* speed and direction of the moving shapes.
66
*/
77

8+
float xpos1;
9+
float xpos2;
10+
float xpos3;
11+
float xpos4;
812
int thin = 8;
913
int thick = 36;
10-
float xpos1 = 134.0;
11-
float xpos2 = 44.0;
12-
float xpos3 = 58.0;
13-
float xpos4 = 120.0;
1414

1515
void setup()
1616
{
17-
size(200, 200);
17+
size(640, 360);
1818
noStroke();
19-
frameRate(60);
19+
xpos1 = width/2;
20+
xpos2 = width/2;
21+
xpos3 = width/2;
22+
xpos4 = width/2;
2023
}
2124

2225
void draw()

‎java/examples/Basics/Math/Distance2D/Distance2D.pde‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
float max_distance;
1010

1111
void setup() {
12-
size(200, 200);
12+
size(640, 360);
1313
smooth();
1414
noStroke();
1515
max_distance = dist(0, 0, width, height);
1616
}
1717

1818
void draw()
1919
{
20-
background(51);
20+
background(0);
2121

2222
for(int i = 0; i <= width; i += 20) {
2323
for(int j = 0; j <= height; j += 20) {

‎java/examples/Basics/Math/DoubleRandom/DoubleRandom.pde‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@
66
* to create an irregular sawtooth line.
77
*/
88

9-
size(200, 200);
10-
background(0);
119
int totalPts = 300;
1210
float steps = totalPts + 1;
13-
stroke(255);
14-
float rand = 0;
11+
12+
void setup() {
13+
size(640, 360);
14+
stroke(255);
15+
frameRate(1);
16+
}
1517

16-
for (int i = 1; i < steps; i++){
17-
point( (width/steps) * i, (height/2) + random(-rand, rand) );
18-
rand += random(-5, 5);
18+
void draw() {
19+
background(0);
20+
float rand = 0;
21+
for (int i = 1; i < steps; i++) {
22+
point( (width/steps) * i, (height/2) + random(-rand, rand) );
23+
rand += random(-5, 5);
24+
}
1925
}
2026

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL