Skip to content

Commit b766686

Browse files
committed
Updates to some of the oldest examples to fit with current style
1 parent 8f77bd6 commit b766686

4 files changed

Lines changed: 44 additions & 60 deletions

File tree

content/examples/Basics/Structure/Coordinates/Coordinates.pde

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* All shapes drawn to the screen have a position that is
55
* specified as a coordinate. All coordinates are measured
66
* as the distance from the origin in units of pixels.
7-
* The origin [0, 0] is the coordinate is in the upper left
7+
* The origin (0, 0) is the coordinate is in the upper left
88
* of the window and the coordinate in the lower right is
9-
* [width-1, height-1].
9+
* (width-1, height-1).
1010
*/
1111

1212
// Sets the screen to be 640 pixels wide and 360 pixels high
@@ -16,22 +16,22 @@ size(640, 360);
1616
background(0);
1717
noFill();
1818

19-
// The two parameters of the point() method each specify coordinates.
20-
// The first parameter is the x-coordinate and the second is the Y
19+
// The two parameters of the point() function define its location.
20+
// The first parameter is the x-coordinate and the second is the y-coordinate
2121
stroke(255);
22-
point(width * 0.5, height * 0.5);
23-
point(width * 0.5, height * 0.25);
22+
point(320, 180);
23+
point(320, 90);
2424

2525
// Coordinates are used for drawing all shapes, not just points.
2626
// Parameters for different functions are used for different purposes.
2727
// For example, the first two parameters to line() specify
2828
// the coordinates of the first endpoint and the second two parameters
2929
// specify the second endpoint
3030
stroke(0, 153, 255);
31-
line(0, height*0.33, width, height*0.33);
31+
line(0, 120, 640, 120);
3232

33-
// By default, the first two parameters to rect() are the
34-
// coordinates of the upper-left corner and the second pair
35-
// is the width and height
33+
// The first two parameters to rect() are the coordinates of the
34+
// upper-left corner and the second pair is the width and height
35+
// of the rectangle
3636
stroke(255, 153, 0);
37-
rect(width*0.25, height*0.1, width * 0.5, height * 0.8);
37+
rect(160, 36, 320, 288);

content/examples/Basics/Structure/Loop/Loop.pde

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
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
7-
* click the mouse to execute loop(), which will
8-
* cause the draw() the execute continuously.
4+
* If noLoop() is run in setup(), the code in draw()
5+
* is only run once. In this example, click the mouse
6+
* to run the loop() function to cause the draw() the
7+
* run continuously.
98
*/
109

11-
float y = 100;
10+
float y = 180;
1211

1312
// The statements in the setup() function
1413
// run once when the program begins
1514
void setup() {
1615
size(640, 360); // Size should be the first statement
1716
stroke(255); // Set stroke color to white
1817
noLoop();
19-
20-
y = height * 0.5;
2118
}
2219

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.
2720
void draw() {
28-
background(0); // Set the background to black
21+
background(0); // Set the background to black
2922
line(0, y, width, y);
30-
3123
y = y - 1;
3224
if (y < 0) {
3325
y = height;
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
/**
22
* No Loop.
33
*
4-
* The noLoop() function causes draw() to only
5-
* execute once. Without calling noLoop(), the
6-
* code inside draw() is run continually.
4+
* The noLoop() function causes draw() to only run once.
5+
* Without calling noLoop(), the code inside draw() is
6+
* run continually.
77
*/
88

9-
float y;
9+
float y = 180;
1010

11-
// The statements in the setup() function
12-
// execute once when the program begins
13-
void setup()
14-
{
11+
// The statements in the setup() block
12+
// run once when the program begins
13+
void setup() {
1514
size(640, 360); // Size should be the first statement
16-
stroke(255); // Set line drawing color to white
15+
stroke(255); // Set line drawing color to white
1716
noLoop();
18-
19-
y = height * 0.5;
2017
}
2118

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.
26-
void draw()
27-
{
19+
// In this example, the code in the draw() block
20+
// runs only once because of the noLoop() in setup()
21+
void draw() {
2822
background(0); // Set the background to black
23+
line(0, y, width, y);
2924
y = y - 1;
3025
if (y < 0) { y = height; }
31-
line(0, y, width, y);
3226
}
33-
34-

content/examples/Basics/Structure/SetupDraw/SetupDraw.pde

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
* Setup and Draw.
33
*
44
* The code inside the draw() function runs continuously
5-
* from top to bottom until the program is stopped.
5+
* from top to bottom until the program is stopped. The
6+
* code in setup() is run once when the program starts.
67
*/
78

8-
int y = 100;
9+
int y = 180;
910

10-
// The statements in the setup() function
11-
// execute once when the program begins
11+
// The statements in the setup() block run once
12+
// when the program begins
1213
void setup() {
1314
size(640, 360); // Size must be the first statement
14-
stroke(255); // Set line drawing color to white
15-
frameRate(30);
15+
stroke(255); // Set line drawing color to white
1616
}
17-
// The statements in draw() are executed until the
18-
// program is stopped. Each statement is executed in
19-
// sequence and after the last line is read, the first
20-
// line is executed again.
17+
18+
// The statements in draw() are run until the program
19+
// is stopped. Each statement is run in sequence from top
20+
// to bottom and after the last line is read, the
21+
// first line is run again.
2122
void draw() {
22-
background(0); // Clear the screen with a black background
23+
background(0); // Clear the screen with a black background
24+
line(0, y, width, y);
2325
y = y - 1;
2426
if (y < 0) {
25-
y = height;
26-
}
27-
line(0, y, width, y);
27+
y = height;
28+
}
2829
}
29-

0 commit comments

Comments
 (0)