Skip to content

Commit 9be82fd

Browse files
authored
Merge pull request #225 from processing/examples-cleanup
Examples updates for 4 beta 2
2 parents f81b708 + 12a93ae commit 9be82fd

File tree

16 files changed

+55
-60
lines changed

16 files changed

+55
-60
lines changed

content/examples/Basic Examples/Color/Hue/Hue.pde

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@
99
int barWidth = 20;
1010
int lastBar = -1;
1111

12-
void setup()
13-
{
12+
void setup() {
1413
size(640, 360);
1514
colorMode(HSB, height, height, height);
1615
noStroke();
1716
background(0);
1817
}
1918

20-
void draw()
21-
{
19+
void draw() {
2220
int whichBar = mouseX / barWidth;
2321
if (whichBar != lastBar) {
2422
int barX = whichBar * barWidth;

content/examples/Basic Examples/Data/CharactersStrings/liveSketch.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@
1616
* featured below.
1717
*/
1818

19-
// The next line is needed if running in JavaScript Mode with Processing.js
20-
/* @pjs font="Georgia.ttf"; */
21-
2219
function runLiveSketch(s) {
2320
var letter = '';
2421
var words = 'Begin...';
2522

2623
s.setup = () => {
2724
s.createCanvas(640, 360);
2825
// Create the font
29-
s.textFont('Georgia', 36);
26+
s.textFont('Source Code Pro', 36);
3027
};
3128

3229
s.draw = () => {

content/examples/Basic Examples/Data/DatatypeConversion/liveSketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function runLiveSketch(s) {
1616
s.background(0);
1717
s.noStroke();
1818

19-
s.textFont('Georgia', 24);
19+
s.textFont('Source Code Pro', 24);
2020

2121
var c; // Chars are used for storing alphanumeric symbols
2222
var f; // Floats are decimal numbers

content/examples/Basic Examples/Input/Easing/liveSketch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function runLiveSketch(s) {
2828
x += dx * easing;
2929
}
3030

31-
var targetY = mouseY;
31+
var targetY = s.mouseY;
3232
var dy = targetY - y;
3333
if (s.abs(dy) > 1) {
3434
y += dy * easing;

content/examples/Basic Examples/Input/MouseSignals/liveSketch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ function runLiveSketch(s) {
3535
bvals[i - 1] = bvals[i];
3636
}
3737
// Add the new values to the end of the array
38-
xvals[width - 1] = s.mouseX;
39-
yvals[width - 1] = s.mouseY;
38+
xvals[s.width - 1] = s.mouseX;
39+
yvals[s.width - 1] = s.mouseY;
4040
if (s.mouseIsPressed) {
41-
bvals[width - 1] = 0;
41+
bvals[s.width - 1] = 0;
4242
} else {
43-
bvals[width - 1] = 255;
43+
bvals[s.width - 1] = 255;
4444
}
4545

4646
s.fill(255);

content/examples/Basic Examples/Math/Interpolate/Interpolate.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Move the mouse across the screen and the symbol will follow.
55
* Between drawing each frame of the animation, the ellipse moves
66
* part of the distance (0.05) from its current position toward
7-
* the cursor using the lerp() function
7+
* the cursor using the lerp() function.
88
*
99
* This is the same as the Easing under input only with lerp() instead.
1010
*/
@@ -32,4 +32,4 @@ void draw() {
3232
fill(255);
3333
stroke(255);
3434
ellipse(x, y, 66, 66);
35-
}
35+
}

content/examples/Basic Examples/Shape/DisableStyle/DisableStyle.pde

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
2-
* Ignore Styles.
3-
* Illustration by George Brower.
2+
* Disable Style
3+
* by George Brower.
44
*
55
* Shapes are loaded with style information that tells them how
6-
* to draw (the color, stroke weight, etc.) The disableStyle()
7-
* method of PShape turns off this information. The enableStyle()
8-
* method turns it back on.
6+
* to draw (e.g. color, stroke weight). The disableStyle()
7+
* method of PShape turns off this information so functions like
8+
* stroke() and fill() change the SVGs color. The enableStyle()
9+
* method turns the file's original styles back on.
910
*/
1011

1112
PShape bot;

content/examples/Basic Examples/Structure/Loop/liveSketch.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Loop.
33
*
4-
* The loop() function causes draw() to execute
5-
* continuously. If noLoop is called in setup()
6-
* the draw() is only executed once. In this example
4+
* The loop() function causes draw() to run
5+
* continuously. If noLoop() is called in setup()
6+
* the draw() is only run once. In this example
77
* click the mouse to execute loop(), which will
8-
* cause the draw() the execute continuously.
8+
* cause the draw() the run continuously.
99
*/
1010
function runLiveSketch(s) {
1111
var y = 100;
@@ -20,10 +20,10 @@ function runLiveSketch(s) {
2020
y = s.height * 0.5;
2121
};
2222

23-
// The statements in draw() are run until the
24-
// program is stopped. Each statement is run in
25-
// sequence and after the last line is read, the first
26-
// line is run again.
23+
// The code in draw() is run until the program
24+
// is stopped. Each statement is executed in
25+
// sequence and after the last line is read,
26+
// the first line is run again.
2727
s.draw = () => {
2828
s.background(0); // Set the background to black
2929
s.line(0, y, s.width, y);
@@ -34,7 +34,7 @@ function runLiveSketch(s) {
3434
}
3535
};
3636

37-
function mousePressed() {
37+
s.mousePressed() {
3838
s.loop();
3939
}
4040
}

content/examples/Basic Examples/Structure/NoLoop/liveSketch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* No Loop.
33
*
44
* The noLoop() function causes draw() to only
5-
* execute once. Without calling noLoop(), the
5+
* run once. Without calling noLoop(), the
66
* code inside draw() is run continually.
77
*/
88

@@ -19,10 +19,10 @@ function runLiveSketch(s) {
1919
y = s.height * 0.5;
2020
};
2121

22-
// The statements in draw() are executed until the
23-
// program is stopped. Each statement is executed in
24-
// sequence and after the last line is read, the first
25-
// line is executed again.
22+
// The code in draw() is run until the program
23+
// is stopped. Each statement is executed in
24+
// sequence and after the last line is read,
25+
// the first line is run again.
2626
s.draw = () => {
2727
s.background(0); // Set the background to black
2828
y = y - 1;

content/examples/Basic Examples/Structure/Redraw/liveSketch.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ function runLiveSketch(s) {
1818
y = s.height * 0.5;
1919
};
2020

21-
// The statements in draw() are executed until the
22-
// program is stopped. Each statement is executed in
23-
// sequence and after the last line is read, the first
24-
// line is executed again.
21+
// The code in draw() is run until the program
22+
// is stopped. Each statement is executed in
23+
// sequence and after the last line is read,
24+
// the first line is run again.
2525
s.draw = () => {
2626
s.background(0); // Set the background to black
2727
y = y - 4;
@@ -31,7 +31,7 @@ function runLiveSketch(s) {
3131
s.line(0, y, s.width, y);
3232
};
3333

34-
function mousePressed() {
34+
s.mousePressed() {
3535
s.redraw();
3636
}
3737
}

0 commit comments

Comments
 (0)