Skip to content

Commit 4509797

Browse files
committed
All .pde updated to Processing 3
All .pde updated to Processing 3
1 parent cc6f0ce commit 4509797

8 files changed

+17
-103
lines changed

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ Updated sketches for Processing v3 from the following repos :
1212

1313
*grid1_0 has not been updated yet as the required lib "gifAnimation" is not updated for v3 yet.
1414

15-
Mostly just moving stuff from setup() that is now required to be in settings() (good naming scheme there, not confusing at all...)
16-
17-
According to the docs, "*The `settings()` method runs before the sketch has been set up, so other Processing functions cannot be used at that point. For instance, do not use `loadImage()` inside `settings()`.*" - [source](https://processing.org/reference/settings_.html) and "*If you must change the size of your sketch, use `surface.setSize(w, h)` which is the one and only (safe) way to alter your sketch's size.*" - [source](https://github.com/processing/processing/wiki/Changes-in-3.0) ... But! Using `loadImage()` in `settings()` works (for now ?) while ~~starting with a default sized window and then using `surface.setSize()` breaks a bunch of the effects - including my fav, ruttetraEmulator (see ruttetraEmulator\broken-ruttetra.pde for a non-working example that follows the docs (as of 2015-02-17) as I understand them.~~ Ok, so I had misread it, setSize happens on the NEXT `draw()`, so we just skip the 1st frame and this works as the docs say after all, see _ruttetraEmulator.pde_, and I'll update the rest at some point as following the docs will futureproof the effects.
15+
Mostly just making sure they follow the rule `Do not use variables in size()` - [source](https://github.com/processing/processing/wiki/Changes-in-3.0)

ruttetraEmulator/ruttetraEmulator-WithVariation-renameMeToTry.pde

+3-9
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ int zoom = 100; // zoom image
1616

1717
void setup() {
1818
size(100,100,P3D);
19-
surface.setResizable(true);
20-
frameLimit++; // (since the 1st frame is 1 rather than 0, we also offset by one.)
19+
img = loadImage(name + "." + type);
20+
surface.setSize(img.width,img.height);
21+
println("christian attard, 2015 @ introwerks");
2122
}
2223

2324
void draw() {
24-
img = loadImage(name + "." + type);
25-
surface.setSize(img.width,img.height);
2625
background(0);
27-
println("christian attard, 2015 @ introwerks");
2826

29-
/* wait until the next frame so the setSize we just did is applied
30-
* otherwise you just get the black bg with a 100*100 image stamped on it.
31-
* Great.
32-
*/
3327
if (frameCount > 1 && frameCount <= frameLimit ){
3428

3529
for (int i = 0; i < img.width; i+=space) {

ruttetraEmulator/ruttetraEmulator-with variations-RENAME to use.pde

-53
This file was deleted.

vhs/vhs.pde

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@ Boolean interactive = true;
99

1010
void setup() {
1111
size(100,100,P2D);
12-
surface.setResizable(true);
13-
}
14-
15-
void draw() {
1612
timg = loadImage("source.jpg");
1713
img1 = createImage(virtw,virth,RGB);
1814
img1.copy(timg,0,0,timg.width,timg.height,0,0,img1.width,img1.height);
1915
surface.setSize(timg.width, timg.height);
16+
}
2017

21-
if (frameCount == 1 ) // skip 1st frame as setSize happens NEXT frame ...
22-
return;
23-
18+
void draw() {
2419
PImage hai = new Subtitle(txt).run(img1);
2520
PImage hay = sinwav(hai,1+(int)(random(1)*6),1+(int)(random(1)*6));
2621
PImage result = createImage(timg.width,timg.height,RGB);

vmap/vmap.pde

+4-9
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,14 @@ float getChannel(color c) {
8080
}
8181

8282
void setup() {
83-
println("christian attard, 2015 @ introwerks");
8483
size(100,100,P3D);
85-
surface.setResizable(true);
86-
}
87-
88-
void draw() {
8984
img = loadImage(name + "." + type);
9085
surface.setSize(img.width,img.height);
86+
println("christian attard, 2015 @ introwerks");
87+
}
9188

92-
if (frameCount == 1 ) // skip 1st frame as setSize happens NEXT frame ...
93-
return;
94-
95-
background(0);
89+
void draw() {
90+
background(0);
9691
lights();
9792
for (int i =0; i<img.width; i+=vSize) {
9893
for (int j =0; j<img.height; j+=vSize) {

wahwah/wahwah.pde

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,19 @@ int arg2 = 20; // 0-100
88

99
void setup() {
1010
size(100,100,P2D);
11-
surface.setResizable(true);
12-
}
13-
14-
void draw() {
1511
img1 = loadImage("source.jpg");
1612
surface.setSize(img1.width,img1.height);
13+
}
1714

18-
if (frameCount == 1 ) // skip 1st frame as setSize happens NEXT frame ...
19-
return;
2015

16+
void draw() {
2117
background(0);
2218
image(wahwah(img1,arg1,arg2),0,0);
2319
save("result.png");
2420
exit();
2521
}
2622

2723

28-
2924
PImage wahwah(PImage img, int xp, int yp) {
3025
float phase, lfoskip, xn1, xn2, yn1, yn2, b0, b1, b2, a0, a1, a2, freqofs, freq, freqoff, startphase, res, depth;
3126
float mCurRate = 0.4, skipcount = 0;

yade/yade.pde

+2-7
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ int blendmode = LIGHTEST;
99

1010
void setup() {
1111
size(100,100,P3D);
12-
surface.setResizable(true);
13-
}
14-
15-
void draw() {
1612
_img = loadImage("source.jpg");
1713
map = loadImage("source.jpg");
1814
surface.setSize(_img.width, _img.height);
1915
img = _img;
2016
background(!autobg ? 0 : _img.pixels[1]);
17+
}
2118

22-
if (frameCount == 1 ) // skip 1st frame as setSize happens NEXT frame ...
23-
return;
24-
19+
void draw() {
2520
float x, y, h, w;
2621
float tw = (float)img.width/(float)tiles;
2722
float th = (float)img.height/(float)tiles;

zigzag/zigzag.pde

+3-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
PImage img;
6-
int barwidth = 6;
6+
int barwidth = 5;
77
int picspace = 2;
88
int minbright = 20;
99
int zigheight = 40;
@@ -12,17 +12,12 @@ Boolean bothsides = true;
1212

1313
void setup() {
1414
size(100,100,P3D);
15-
surface.setResizable(true);
15+
img = loadImage("source.jpg");
16+
surface.setSize(img.width, img.height);
1617
frameRate(1);
1718
}
1819

1920
void draw() {
20-
img = loadImage("source.jpg");
21-
surface.setSize(img.width, img.height);
22-
23-
if (frameCount == 1 ) // skip 1st frame as setSize happens NEXT frame ...
24-
return;
25-
2621
Boolean bw = true;
2722
img.loadPixels();
2823
for (int y = 0, h = img.height; y<h; y++) {

0 commit comments

Comments
 (0)