Skip to content

Commit 89235f3

Browse files
committed
another round of example updates for processing#154
1 parent cb8f54e commit 89235f3

File tree

20 files changed

+46
-44
lines changed

20 files changed

+46
-44
lines changed

content/examples/Topics/File IO/SaveFile1/SaveFile1.pde

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
* Saving files is a useful way to store data so it can be viewed after a
55
* program has stopped running. The saveStrings() function writes an array
66
* of strings to a file, with each string written to a new line. This file
7-
* is saved to the sketch's folder. This example won't work in a web browser
8-
* because of Java security restrictions.
7+
* is saved to the sketch's folder.
98
*/
109

1110
int[] x = new int[0];

content/examples/Topics/File IO/SaveFile2/SaveFile2.pde

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*
44
* This file a PrintWriter object to write data continuously to a file
55
* while the mouse is pressed. When a key is pressed, the file closes
6-
* itself and the program is stopped. This example won't work in a web browser
7-
* because of Java security restrictions.
6+
* itself and the program is stopped.
87
*/
98

109
PrintWriter output;

content/examples_p5/Topics/Advanced Data/LoadSaveTable/LoadSaveTable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ function draw() {
4545

4646
textAlign(LEFT);
4747
fill(0);
48+
noStroke();
4849
text("Click to add bubbles.", 10, height-10);
4950
}
5051

content/examples_p5/Topics/Advanced Data/XMLYahooWeather/XMLYahooWeather.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@
1111
// We're going to store the temperature
1212
var temperature = 0;
1313
// We're going to store text about the weather
14-
String weather = "";
14+
var weather = "";
1515

1616
// The zip code we'll check for
17-
String zip = "10003";
17+
var zip = "10003";
1818

19-
PFont font;
19+
var xml;
20+
21+
function preload() {
22+
var url = "http://xml.weather.yahoo.com/forecastrss?p=" + zip;
23+
// Load the XML document
24+
xml = loadXML(url);
25+
26+
}
2027

2128
function setup() {
2229
createCanvas(600, 360);
2330

24-
font = createFont("Merriweather-Light.ttf", 28);
25-
textFont(font);
31+
textFont("Merriweather Light", 28);
2632

2733
// The URL for the XML document
28-
String url = "http://xml.weather.yahoo.com/forecastrss?p=" + zip;
29-
30-
// Load the XML document
31-
XML xml = loadXML(url);
3234

3335
// Grab the element we want
34-
XML forecast = xml.getChild("channel/item/yweather:forecast");
36+
var forecast = xml.getChild("channel/item/yweather:forecast");
3537

3638
// Get the attributes we want
3739
temperature = forecast.getInt("high");

content/examples_p5/Topics/Cellular Automata/Spore1/Spore1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var runs_per_loop = 100;
2222
function setup() {
2323
var canvas = createCanvas(640, 360);
2424
canvas.parent("p5container");
25-
devicePixelScaling(false);
25+
pixelDensity(1);
2626
frameRate(24);
2727
reset();
2828
}

content/examples_p5/Topics/File IO/LoadFile1/LoadFile1.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ var lines;
99
var index = 0;
1010

1111
function preload() {
12-
lines = loadStrings("/positions.txt");
12+
lines = loadStrings("positions.txt");
1313
}
1414

1515
function setup() {
16-
createCanvas(200, 200);
16+
var canvas = createCanvas(200, 200);
17+
canvas.parent("p5container");
1718
background(0);
1819
stroke(255);
1920
frameRate(12);

content/examples_p5/Topics/File IO/LoadFile2/LoadFile2.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ var num = 9; // Display this many entries on each screen.
1414
var startingEntry = 0; // Display from this entry number
1515

1616
function preload() {
17-
lines = loadStrings("/cars2.tsv");
17+
lines = loadStrings("cars2.tsv");
1818
}
1919

2020
function setup() {
21-
createCanvas(200, 200);
21+
var canvas = createCanvas(200, 200);
22+
canvas.parent("p5container");
2223
fill(255);
2324
noLoop();
2425

content/examples_p5/Topics/File IO/SaveFile1/SaveFile1.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@
44
* Saving files is a useful way to store data so it can be viewed after a
55
* program has stopped running. The saveStrings() function writes an array
66
* of strings to a file, with each string written to a new line. This file
7-
* is saved to the sketch's folder. This example won't work in a web browser
8-
* because of Java security restrictions.
7+
* is saved to the sketch's folder.
98
*/
109

1110
var x = [];
1211
var y = [];
1312

14-
function setup()
15-
{
16-
createCanvas(200, 200);
13+
function setup() {
14+
var canvas = createCanvas(200, 200);
15+
canvas.parent("p5container");
1716
}
1817

19-
function draw()
20-
{
18+
function draw() {
2119
background(204);
2220
stroke(0);
2321
noFill();
@@ -43,7 +41,7 @@ function keyPressed() { // Press a key to save the data
4341
for (var i = 0; i < x.length; i++) {
4442
lines[i] = x[i] + "\t" + y[i];
4543
}
46-
saveStrings(lines,"lines.txt");
44+
saveStrings(lines, "lines.txt");
4745
//exit(); // Stop the program
4846
}
4947

content/examples_p5/Topics/File IO/SaveOneFrame/SaveOneImage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*/
99

1010
function setup() {
11-
createCanvas(200, 200);
11+
var canvas = createCanvas(200, 200);
12+
canvas.parent("p5container");
1213
}
1314

1415
function draw() {

content/examples_p5/Topics/Fractals and L-Systems/Koch/KochLine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ function KochLine(a,b) {
1010
// Two p5.Vectors,
1111
// start is the "left" p5.Vector and
1212
// end is the "right p5.Vector
13-
this.start = a.get();
14-
this.end = b.get();
13+
this.start = a.copy();
14+
this.end = b.copy();
1515

1616
this.display = function() {
1717
stroke(255);

0 commit comments

Comments
 (0)