Skip to content

Commit dbfbfb9

Browse files
committed
Changes to example XML
1 parent 938727d commit dbfbfb9

13 files changed

Lines changed: 308 additions & 341 deletions

File tree

content/examples.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<cat label="Objects">
104104
<ex file="Objects.html">Objects</ex>
105105
<ex file="MultipleConstructors.html">Multiple Constructors</ex>
106-
<ex file="Composite Objects.html">Composite Objects</ex>
106+
<ex file="CompositeObjects.html">Composite Objects</ex>
107107
<ex file="Inheritance.html">Inheritance</ex>
108108
</cat>
109109
<cat label="Web">
Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
/**
2-
* Bezier.
3-
*
4-
* The first two parameters for the bezier() function specify the
5-
* first point in the curve and the last two parameters specify
6-
* the last point. The middle parameters set the control points
7-
* that define the shape of the curve.
8-
*
9-
* Created 16 January 2003
10-
*/
11-
12-
size(200, 200);
13-
background(0);
14-
stroke(255);
15-
smooth();
16-
17-
for(int i=0; i<100; i+=10) {
18-
bezier(90-(i/2.0), 20+i, 210, 10, 220, 150, 120-(i/8.0), 150+(i/4.0));
19-
}
1+
/**
2+
* Bezier.
3+
*
4+
* The first two parameters for the bezier() function specify the
5+
* first point in the curve and the last two parameters specify
6+
* the last point. The middle parameters set the control points
7+
* that define the shape of the curve.
8+
*
9+
* Created 16 January 2003
10+
*/
11+
12+
size(200, 200);
13+
background(0);
14+
stroke(255);
15+
noFill();
16+
smooth();
17+
18+
for(int i = 0; i < 100; i += 20) {
19+
bezier(90-(i/2.0), 20+i, 210, 10, 220, 150, 120-(i/8.0), 150+(i/4.0));
20+
}
Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,49 @@
1-
/**
2-
* Vertices.
3-
*
4-
* The beginShape() function begins recording vertices
5-
* for a shape and endShape() stops recording.
6-
* A vertex is a location in space specified by X, Y,
7-
* and sometimes Z coordinates. beginShape() requires a parameter
8-
* to tell it which type of shape to create from the provided vertices.
9-
* The choices available are LINES, LINE_STRIP, LINE_LOOP, TRIANGLES,
10-
* TRIANGLE_STRIP, QUADS, QUAD_STRIP, and POLYGON. After calling the
11-
* beginShape() function, a series of vertex() functions must follow.
12-
* To stop drawing the shape, call the endShape() functions.
13-
*
14-
* Created 2 September 2002
15-
*/
16-
17-
size(200, 200);
18-
background(0);
19-
noFill();
20-
21-
stroke(102);
22-
beginShape();
23-
curveVertex(168, 182);
24-
curveVertex(168, 182);
25-
curveVertex(136, 38);
26-
curveVertex(42, 34);
27-
curveVertex(64, 200);
28-
curveVertex(64, 200);
29-
endShape();
30-
31-
stroke(51);
32-
beginShape(LINES);
33-
vertex(60, 40);
34-
vertex(160, 10);
35-
vertex(170, 150);
36-
vertex(60, 150);
37-
endShape();
38-
39-
stroke(126);
40-
beginShape();
41-
vertex(60, 40);
42-
bezierVertex(160, 10, 170, 150, 60, 150);
43-
endShape();
44-
45-
stroke(255);
46-
beginShape(POINTS);
47-
vertex(60, 40);
48-
vertex(160, 10);
49-
vertex(170, 150);
50-
vertex(60, 150);
51-
endShape();
52-
1+
/**
2+
* Vertices.
3+
*
4+
* The beginShape() function begins recording vertices
5+
* for a shape and endShape() stops recording.
6+
* A vertex is a location in space specified by X, Y,
7+
* and sometimes Z coordinates. After calling the beginShape() function,
8+
* a series of vertex() functions must follow.
9+
* To stop drawing the shape, call the endShape() functions.
10+
*
11+
* Created 2 September 2002
12+
*/
13+
14+
size(200, 200);
15+
background(0);
16+
noFill();
17+
18+
stroke(102);
19+
beginShape();
20+
curveVertex(168, 182);
21+
curveVertex(168, 182);
22+
curveVertex(136, 38);
23+
curveVertex(42, 34);
24+
curveVertex(64, 200);
25+
curveVertex(64, 200);
26+
endShape();
27+
28+
stroke(51);
29+
beginShape(LINES);
30+
vertex(60, 40);
31+
vertex(160, 10);
32+
vertex(170, 150);
33+
vertex(60, 150);
34+
endShape();
35+
36+
stroke(126);
37+
beginShape();
38+
vertex(60, 40);
39+
bezierVertex(160, 10, 170, 150, 60, 150);
40+
endShape();
41+
42+
stroke(255);
43+
beginShape(POINTS);
44+
vertex(60, 40);
45+
vertex(160, 10);
46+
vertex(170, 150);
47+
vertex(60, 150);
48+
endShape();
49+
Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
1-
/**
2-
* Background Image.
3-
*
4-
* This example presents the fastest way to load a background image
5-
* into Processing.
6-
*
7-
* Created 16 January 2003
8-
*/
9-
10-
PImage bg;
11-
int a;
12-
13-
void setup()
14-
{
15-
size(200,200);
16-
frameRate(30);
17-
// The background image must be the same size as the parameters
18-
// into the size() method. In this program, the size of "milan_rubbish.jpg"
19-
// is 200 x 200 pixels.
20-
bg = loadImage("milan_rubbish.jpg");
21-
}
22-
23-
void draw()
24-
{
25-
background(bg);
26-
27-
a = (a + 1)%(width+32);
28-
stroke(226, 204, 0);
29-
line(0, a, width, a-26);
30-
line(0, a-6, width, a-32);
31-
}
1+
/**
2+
* Background Image.
3+
*
4+
* This example presents the fastest way to load a background image
5+
* into Processing. To load an image as the background, it must be
6+
* the same width and height as the program.
7+
*
8+
* Created 16 January 2003
9+
*/
10+
11+
PImage bg;
12+
int a;
13+
14+
void setup()
15+
{
16+
size(200,200);
17+
frameRate(30);
18+
// The background image must be the same size as the parameters
19+
// into the size() method. In this program, the size of "milan_rubbish.jpg"
20+
// is 200 x 200 pixels.
21+
bg = loadImage("milan_rubbish.jpg");
22+
}
23+
24+
void draw()
25+
{
26+
background(bg);
27+
28+
a = (a + 1)%(width+32);
29+
stroke(226, 204, 0);
30+
line(0, a, width, a-26);
31+
line(0, a-6, width, a-32);
32+
}
Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,32 @@
1-
/**
2-
* Transparency.
3-
*
4-
* Move the pointer left and right across the image to change
5-
* its position. This program overlays one image over another
6-
* by modifying the alpha value of the image.
7-
*
8-
* Created 09 December 2002
9-
*/
10-
11-
PImage a, b;
12-
boolean once = false;
13-
int[] buffer;
14-
float bufferOffset, newBufferOffset;
15-
16-
void setup()
17-
{
18-
size(200, 200);
19-
buffer = new int[width*height];
20-
bufferOffset = newBufferOffset = 0.0;
21-
a = loadImage("construct.jpg"); // Load an image into the program
22-
b = loadImage("wash.jpg"); // Load an image into the program
23-
frameRate(60);
24-
}
25-
26-
void draw()
27-
{
28-
image(a, 0, 0);
29-
30-
newBufferOffset = -b.width/2 + (mouseX*2-width/2);
31-
float distance = bufferOffset - newBufferOffset;
32-
if( abs(distance) > 0.01 ) {
33-
bufferOffset -= distance/10.0;
34-
bufferOffset = constrain(bufferOffset, -400, 0);
35-
}
36-
tint(255, 153);
37-
image(b, bufferOffset, 20);
38-
}
39-
40-
41-
42-
43-
1+
/**
2+
* Transparency.
3+
*
4+
* Move the pointer left and right across the image to change
5+
* its position. This program overlays one image over another
6+
* by modifying the alpha value of the image with the tint() function.
7+
*/
8+
9+
PImage a, b;
10+
float offset;
11+
12+
void setup()
13+
{
14+
size(200, 200);
15+
a = loadImage("construct.jpg"); // Load an image into the program
16+
b = loadImage("wash.jpg"); // Load an image into the program
17+
frameRate(60);
18+
}
19+
20+
void draw()
21+
{
22+
image(a, 0, 0);
23+
float offsetTarget = map(mouseX, 0, width, -b.width/2 - width/2, 0);
24+
offset += (offsetTarget-offset)*0.05;
25+
tint(255, 153);
26+
image(b, offset, 20);
27+
}
28+
29+
30+
31+
32+
Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
/**
2-
* Constrain.
3-
*
4-
* Move the mouse across the screen to move the circle.
5-
* The program constrains the circle to its box.
6-
*
7-
* Updated 20 January 2003
8-
*/
9-
10-
float mx;
11-
float my;
12-
float delay = 40.0;
13-
float esize = 25.0;
14-
int box = 30;
15-
16-
void setup()
17-
{
18-
size(200, 200);
19-
noStroke();
20-
smooth();
21-
ellipseMode(CENTER_RADIUS);
22-
}
23-
24-
void draw()
25-
{
26-
background(51);
27-
28-
if(abs(mouseX - mx) > 0.1) {
29-
mx = mx + (mouseX - mx)/delay;
30-
}
31-
if(abs(mouseY - my) > 0.1) {
32-
my = my + (mouseY- my)/delay;
33-
}
34-
35-
float distance = esize * 2;
36-
mx = constrain(mx, box+distance, width-box-distance);
37-
my = constrain(my, box+distance, height-box-distance);
38-
fill(76);
39-
rect(box+esize, box+esize, box*3, box*3);
40-
fill(255);
41-
ellipse(mx, my, esize, esize);
42-
}
1+
/**
2+
* Constrain.
3+
*
4+
* Move the mouse across the screen to move the circle.
5+
* The program constrains the circle to its box.
6+
*
7+
* Updated 20 January 2003
8+
*/
9+
10+
float mx;
11+
float my;
12+
float easing = 0.05;
13+
float esize = 25.0;
14+
int box = 30;
15+
16+
void setup()
17+
{
18+
size(200, 200);
19+
noStroke();
20+
smooth();
21+
ellipseMode(CENTER_RADIUS);
22+
}
23+
24+
void draw()
25+
{
26+
background(51);
27+
28+
if(abs(mouseX - mx) > 0.1) {
29+
mx = mx + (mouseX - mx) * easing;
30+
}
31+
if(abs(mouseY - my) > 0.1) {
32+
my = my + (mouseY- my) * easing;
33+
}
34+
35+
float distance = esize * 2;
36+
mx = constrain(mx, box+distance, width-box-distance);
37+
my = constrain(my, box+distance, height-box-distance);
38+
fill(76);
39+
rect(box+esize, box+esize, box*3, box*3);
40+
fill(255);
41+
ellipse(mx, my, esize, esize);
42+
}

0 commit comments

Comments
 (0)