diff --git a/chp06_loops/exercise_06_04_global_vs_local/exercise_06_04_global_vs_local.pde b/chp06_loops/exercise_06_04_global_vs_local/exercise_06_04_global_vs_local.pde
index 2beb4ab..6e11a72 100644
--- a/chp06_loops/exercise_06_04_global_vs_local/exercise_06_04_global_vs_local.pde
+++ b/chp06_loops/exercise_06_04_global_vs_local/exercise_06_04_global_vs_local.pde
@@ -2,7 +2,7 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// Exercise 6-4: Predict the results of the following two
+// Exercise 6-4: Predict the results of the following two
// programs. Test your theory by running them.
/*
@@ -17,10 +17,10 @@ void draw() {
count = count + 1;
background(count);
}
-________
-
-
+// ________
+*/
+/*
//SKETCH #2: Local "count"
void setup() {
@@ -29,8 +29,8 @@ void setup() {
void draw() {
int count = 0;
- count = count = 1;
+ count = count + 1;
background(count);
}
-________
+// ________
*/
diff --git a/chp08_objects/example_08_03_zoogobject/example_08_03_zoogobject.pde b/chp08_objects/example_08_03_zoogobject/example_08_03_zoogobject.pde
index eff868f..2ad051b 100644
--- a/chp08_objects/example_08_03_zoogobject/example_08_03_zoogobject.pde
+++ b/chp08_objects/example_08_03_zoogobject/example_08_03_zoogobject.pde
@@ -3,10 +3,12 @@
// http://www.learningprocessing.com
// Example 8-3
+// Zoog is an object!
Zoog zoog;
void setup() {
size(480, 270);
+ // Zoog is given initial properties via the constructor.
zoog = new Zoog(width/2,height/2,60,60,16);
}
@@ -14,10 +16,14 @@ void draw() {
background(255);
// mouseX position determines speed factor
float factor = constrain(mouseX/10,0,5);
+ // Zoog can do stuff with functions!
zoog.jiggle(factor);
zoog.display();
}
+// Everything about Zoog is contained in this one class.
+// Zoog has properties (location, width, height, eye size)
+// and Zoog has abilities (jiggle, display).
class Zoog {
// Zoog's variables
float x,y,w,h,eyeSize;
diff --git a/chp14_transformations/exercise_14_12_star_class/exercise_14_12_star_class.pde b/chp14_transformations/exercise_14_12_star_class/exercise_14_12_star_class.pde
new file mode 100644
index 0000000..d0f7597
--- /dev/null
+++ b/chp14_transformations/exercise_14_12_star_class/exercise_14_12_star_class.pde
@@ -0,0 +1,28 @@
+// Learning Processing
+// Daniel Shiffman
+// http://www.learningprocessing.com
+
+// Exercise 14-12: Rewrite Example 14-19 so that the
+// PShape object itself is inside your own Star class
+// that also includes x,y variables for position.
+// Make multiple instances of the object an array.
+// Here is some code to get you started.
+
+class Star {
+ // The PShape object
+ PShape s;
+ // The location where I will draw the shape
+ float x,y;
+
+ Star() {
+ // What goes here?
+ }
+
+ void move() {
+ // What goes here?
+ }
+
+ void display() {
+ // What goes here?
+ }
+}
diff --git a/chp17_strings/exercise_17_03_equals/exercise_17_03_equals.pde b/chp17_strings/exercise_17_03_equals/exercise_17_03_equals.pde
index 964b3fe..a464776 100644
--- a/chp17_strings/exercise_17_03_equals/exercise_17_03_equals.pde
+++ b/chp17_strings/exercise_17_03_equals/exercise_17_03_equals.pde
@@ -5,7 +5,7 @@
// Exercise 17-3: Find the duplicates in the following array of Strings.
/*
-String words = { "I" , "love" , "coffee" , "I" , "love" , "tea" } ;
+String words[] = { "I" , "love" , "coffee" , "I" , "love" , "tea" } ;
for (int i = 0; i < ______________; i ++ ) {
for (int j = _; j < ______________; j ++ ) {
if (___________________) {
diff --git a/chp18_data/example_18_06_XMLYahooWeather/example_18_06_XMLYahooWeather.pde b/chp18_data/example_18_06_XMLYahooWeather/example_18_06_XMLYahooWeather.pde
index c67c124..40d269f 100644
--- a/chp18_data/example_18_06_XMLYahooWeather/example_18_06_XMLYahooWeather.pde
+++ b/chp18_data/example_18_06_XMLYahooWeather/example_18_06_XMLYahooWeather.pde
@@ -17,14 +17,9 @@ String city = "";
// Search for "woeid lookup" to find your own.
String woeid = "638242";
-PFont font;
-
void setup() {
size(600, 360);
- font = createFont("Merriweather-Light.ttf", 28);
- textFont(font);
-
// The URL for the XML document
String url = "http://query.yahooapis.com/v1/public/yql?format=xml&q=select+*+from+weather.forecast+where+woeid=" + woeid + "+and+u='C'";
println(url);
@@ -47,8 +42,8 @@ void draw() {
fill(0);
// Display all the stuff we want to display
+ textSize(28);
text("Location: " + city, width*0.15, height*0.33);
text("Today’s high: " + temperature, width*0.15, height*0.5);
text("Forecast: " + weather, width*0.15, height*0.66);
-
}
diff --git a/chp18_data/exercise_18_14_particles_xml/exercise_18_14_particles_xml.pde b/chp18_data/exercise_18_14_particles_xml/exercise_18_14_particles_xml.pde
index 9d607a3..18e5a29 100644
--- a/chp18_data/exercise_18_14_particles_xml/exercise_18_14_particles_xml.pde
+++ b/chp18_data/exercise_18_14_particles_xml/exercise_18_14_particles_xml.pde
@@ -2,40 +2,39 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// lass="exercise"data-type="sidebar"id="use_the_following_xml_document_to_initia">
-// Exercise 18-14: Use the following XML document to initialize an array of
-// objects. Design the objects to use all of the values in each XML element.
-// (Feel free to rewrite the XML document to include more or less data.)
-// If you do not want to retype the XML, it is available at this book's web
+// Exercise 18-14: Use the following XML document to initialize an array of
+// objects. Design the objects to use all of the values in each XML element.
+// (Feel free to rewrite the XML document to include more or less data.)
+// If you do not want to retype the XML, it is available at this book's web
// site.
/*
-
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
+
+
+
-
+
*/
diff --git a/chp19_data_streams/example_19_03_broadcasting_server/example_19_03_broadcasting_server.pde b/chp19_data_streams/example_19_03_broadcasting_server/example_19_03_broadcasting_server.pde
index 1bd18b1..e298930 100644
--- a/chp19_data_streams/example_19_03_broadcasting_server/example_19_03_broadcasting_server.pde
+++ b/chp19_data_streams/example_19_03_broadcasting_server/example_19_03_broadcasting_server.pde
@@ -12,7 +12,7 @@ Server server;
int data = 0;
void setup() {
- size(200, 200, JAVA2D_2X);
+ size(200, 200);
// Create the Server on port 5204
server = new Server(this, 5204);
}
diff --git a/chp19_data_streams/example_19_04_client_bgcolor/example_19_04_client_bgcolor.pde b/chp19_data_streams/example_19_04_client_bgcolor/example_19_04_client_bgcolor.pde
index 1d632a0..4f29230 100644
--- a/chp19_data_streams/example_19_04_client_bgcolor/example_19_04_client_bgcolor.pde
+++ b/chp19_data_streams/example_19_04_client_bgcolor/example_19_04_client_bgcolor.pde
@@ -12,7 +12,7 @@ Client client;
int data;
void setup() {
- size(200, 200, JAVA2D_2X);
+ size(200, 200);
// Create the Client
client = new Client(this, "127.0.0.1", 5204);
}
diff --git a/chp19_data_streams/example_19_05_client_rotation/example_19_05_client_rotation.pde b/chp19_data_streams/example_19_05_client_rotation/example_19_05_client_rotation.pde
index 6fcf721..5f67371 100644
--- a/chp19_data_streams/example_19_05_client_rotation/example_19_05_client_rotation.pde
+++ b/chp19_data_streams/example_19_05_client_rotation/example_19_05_client_rotation.pde
@@ -12,7 +12,7 @@ Client client;
int data;
void setup() {
- size(200, 200, JAVA2D_2X);
+ size(200, 200);
// Create the Client
client = new Client(this, "127.0.0.1", 5204);
}
diff --git a/chp19_data_streams/example_19_06_multiuser_server/example_19_06_multiuser_server.pde b/chp19_data_streams/example_19_06_multiuser_server/example_19_06_multiuser_server.pde
index 4b118af..05cbf61 100644
--- a/chp19_data_streams/example_19_06_multiuser_server/example_19_06_multiuser_server.pde
+++ b/chp19_data_streams/example_19_06_multiuser_server/example_19_06_multiuser_server.pde
@@ -13,7 +13,7 @@ Server server;
String incomingMessage = "";
void setup() {
- size(400, 200,JAVA2D_2X);
+ size(400, 200);
// Create the Server on port 5204
server = new Server(this, 5204);
diff --git a/chp19_data_streams/example_19_07_multiuser_client/example_19_07_multiuser_client.pde b/chp19_data_streams/example_19_07_multiuser_client/example_19_07_multiuser_client.pde
index 79bb99e..b365993 100644
--- a/chp19_data_streams/example_19_07_multiuser_client/example_19_07_multiuser_client.pde
+++ b/chp19_data_streams/example_19_07_multiuser_client/example_19_07_multiuser_client.pde
@@ -8,15 +8,21 @@
import processing.net.*;
// Declare a client
Client client;
+// Store mouse X/Y in this array
+int[] vals = new int[2];
void setup() {
- size(200, 200, JAVA2D_2X);
+ size(200, 200);
// Create the Client
client = new Client(this, "127.0.0.1", 5204);
background(255);
}
void draw() {
+ // Render an ellipse based on the current values
+ fill(0, 100);
+ noStroke();
+ ellipse(vals[0], vals[1], 16, 16);
}
// If there is information available to read from the Server
@@ -27,12 +33,7 @@ void clientEvent(Client client) {
// Print message received
println( "Receiving:" + in);
// The client reads messages from the Server and parses them with splitTokens() according to our protocol.
- int[] vals = int(splitTokens(in, ",\n"));
-
- // Render an ellipse based on those values
- fill(0, 100);
- noStroke();
- ellipse(vals[0], vals[1], 16, 16);
+ vals = int(splitTokens(in, ",\n"));
}
}
@@ -40,9 +41,7 @@ void clientEvent(Client client) {
void mouseDragged() {
// Put the String together with our protocol: mouseX comma mouseY newline
String out = mouseX + "," + mouseY + "\n" ;
- fill(0, 100);
- noStroke();
- ellipse(mouseX, mouseY, 16, 16); // A message is sent whenever the mouse is dragged. Note that a client will receive its own messages! Nothing is drawn here!
+ // A message is sent whenever the mouse is dragged. Note that a client will receive its own messages! Nothing is drawn here!
client.write(out);
// Print a message indicating we have sent data
println("Sending: " + out);
diff --git a/chp19_data_streams/exercise_19_04_clientEvent/exercise_19_04_clientEvent.pde b/chp19_data_streams/exercise_19_04_clientEvent/exercise_19_04_clientEvent.pde
index 84765e3..39046ce 100644
--- a/chp19_data_streams/exercise_19_04_clientEvent/exercise_19_04_clientEvent.pde
+++ b/chp19_data_streams/exercise_19_04_clientEvent/exercise_19_04_clientEvent.pde
@@ -2,7 +2,7 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// Exercise 19-3: Go back and rewrite the therapy client
+// Exercise 19-4: Go back and rewrite the therapy client
// to use clientEvent() rather than
// client.available() in draw(). This is trickier than
// it might initially seem because it requires the use
diff --git a/chp19_data_streams/exercise_19_05_whiteboard_color/exercise_19_05_whiteboard_color.pde b/chp19_data_streams/exercise_19_05_whiteboard_color/exercise_19_05_whiteboard_color.pde
index f3f7b05..cd28f21 100644
--- a/chp19_data_streams/exercise_19_05_whiteboard_color/exercise_19_05_whiteboard_color.pde
+++ b/chp19_data_streams/exercise_19_05_whiteboard_color/exercise_19_05_whiteboard_color.pde
@@ -2,7 +2,7 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// Exercise 19-4: Expand the whiteboard to allow for
+// Exercise 19-5: Expand the whiteboard to allow for
// color. Each client should send a red, green, and blue
// value in addition to the XY location. You will not
// need to make any changes to the server for this to work.
diff --git a/chp19_data_streams/exercise_19_06_pong/exercise_19_06_pong.pde b/chp19_data_streams/exercise_19_06_pong/exercise_19_06_pong.pde
index 34d219a..77eb373 100644
--- a/chp19_data_streams/exercise_19_06_pong/exercise_19_06_pong.pde
+++ b/chp19_data_streams/exercise_19_06_pong/exercise_19_06_pong.pde
@@ -2,7 +2,7 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// Exercise 19-5: Create a two-player game of Pong
+// Exercise 19-6: Create a two-player game of Pong
// played over the network. This is a complex assignment,
// so build it up slowly. For instance, you should get
// Pong to work first without networking (if you are
diff --git a/chp19_data_streams/exercise_19_07_arduino/exercise_19_07_arduino.pde b/chp19_data_streams/exercise_19_07_arduino/exercise_19_07_arduino.pde
index 1041e99..432e143 100644
--- a/chp19_data_streams/exercise_19_07_arduino/exercise_19_07_arduino.pde
+++ b/chp19_data_streams/exercise_19_07_arduino/exercise_19_07_arduino.pde
@@ -2,7 +2,7 @@
// Daniel Shiffman
// http://www.learningprocessing.com
-// Exercise 19-6: If you have an Arduino board, build
+// Exercise 19-7: If you have an Arduino board, build
// your own interface to control a Processing sketch
// you have already made. (Before you attempt this,
// you should make sure you can successfully run the
diff --git a/chp20_sound/example_20_01_playback/data/beat.wav b/chp20_sound/example_20_01_playback/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_01_playback/data/beat.wav differ
diff --git a/chp20_sound/example_20_01_playback/example_20_01_playback.pde b/chp20_sound/example_20_01_playback/example_20_01_playback.pde
index e8154c8..c4824fe 100644
--- a/chp20_sound/example_20_01_playback/example_20_01_playback.pde
+++ b/chp20_sound/example_20_01_playback/example_20_01_playback.pde
@@ -11,7 +11,7 @@ SoundFile song;
void setup() {
size(480, 270);
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
song.play();
}
diff --git a/chp20_sound/example_20_03_manipulate_sound/data/beat.wav b/chp20_sound/example_20_03_manipulate_sound/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_03_manipulate_sound/data/beat.wav differ
diff --git a/chp20_sound/example_20_03_manipulate_sound/example_20_03_manipulate_sound.pde b/chp20_sound/example_20_03_manipulate_sound/example_20_03_manipulate_sound.pde
index 89f15f3..a2f0855 100644
--- a/chp20_sound/example_20_03_manipulate_sound/example_20_03_manipulate_sound.pde
+++ b/chp20_sound/example_20_03_manipulate_sound/example_20_03_manipulate_sound.pde
@@ -13,7 +13,7 @@ void setup() {
size(200, 200);
// Load a sound file
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
// Loop the sound forever
// (well, at least until stop() is called)
diff --git a/chp20_sound/example_20_04_pan/data/beat.wav b/chp20_sound/example_20_04_pan/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_04_pan/data/beat.wav differ
diff --git a/chp20_sound/example_20_04_pan/example_20_04_pan.pde b/chp20_sound/example_20_04_pan/example_20_04_pan.pde
index c9d87fd..9138e1b 100644
--- a/chp20_sound/example_20_04_pan/example_20_04_pan.pde
+++ b/chp20_sound/example_20_04_pan/example_20_04_pan.pde
@@ -4,7 +4,7 @@ SoundFile soundFile;
void setup() {
size(200, 200);
- soundFile = new SoundFile(this, "beat.mp3");
+ soundFile = new SoundFile(this, "beat.wav");
soundFile.loop();
}
diff --git a/chp20_sound/example_20_05_reverb/data/beat.wav b/chp20_sound/example_20_05_reverb/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_05_reverb/data/beat.wav differ
diff --git a/chp20_sound/example_20_05_reverb/example_20_05_reverb.pde b/chp20_sound/example_20_05_reverb/example_20_05_reverb.pde
index 585ea7d..12a1527 100644
--- a/chp20_sound/example_20_05_reverb/example_20_05_reverb.pde
+++ b/chp20_sound/example_20_05_reverb/example_20_05_reverb.pde
@@ -13,7 +13,7 @@ void setup() {
size(200, 200);
// Load a sound file
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
song.loop();
reverb = new Reverb(this);
diff --git a/chp20_sound/example_20_09_playback_analysis/data/beat.wav b/chp20_sound/example_20_09_playback_analysis/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_09_playback_analysis/data/beat.wav differ
diff --git a/chp20_sound/example_20_09_playback_analysis/example_20_09_playback_analysis.pde b/chp20_sound/example_20_09_playback_analysis/example_20_09_playback_analysis.pde
index a4fec8e..1431671 100644
--- a/chp20_sound/example_20_09_playback_analysis/example_20_09_playback_analysis.pde
+++ b/chp20_sound/example_20_09_playback_analysis/example_20_09_playback_analysis.pde
@@ -14,7 +14,7 @@ Amplitude analyzer;
void setup() {
size(480, 270);
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
song.loop();
// create a new Amplitude analyzer
diff --git a/chp20_sound/example_20_13_soundfile_FFT/data/beat.wav b/chp20_sound/example_20_13_soundfile_FFT/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/example_20_13_soundfile_FFT/data/beat.wav differ
diff --git a/chp20_sound/example_20_13_soundfile_FFT/example_20_13_soundfile_FFT.pde b/chp20_sound/example_20_13_soundfile_FFT/example_20_13_soundfile_FFT.pde
index 9ef4208..6de0b4b 100644
--- a/chp20_sound/example_20_13_soundfile_FFT/example_20_13_soundfile_FFT.pde
+++ b/chp20_sound/example_20_13_soundfile_FFT/example_20_13_soundfile_FFT.pde
@@ -13,7 +13,7 @@ int bands = 512;
void setup() {
size(512, 360);
// Create a new sample object.
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
// Loop the sound forever
// (well, at least until stop() is called)
diff --git a/chp20_sound/exercise_20_10_graphic_equalizer/data/beat.wav b/chp20_sound/exercise_20_10_graphic_equalizer/data/beat.wav
new file mode 100644
index 0000000..c2c50d0
Binary files /dev/null and b/chp20_sound/exercise_20_10_graphic_equalizer/data/beat.wav differ
diff --git a/chp20_sound/exercise_20_10_graphic_equalizer/exercise_20_10_graphic_equalizer.pde b/chp20_sound/exercise_20_10_graphic_equalizer/exercise_20_10_graphic_equalizer.pde
index 12a42c6..66bef33 100644
--- a/chp20_sound/exercise_20_10_graphic_equalizer/exercise_20_10_graphic_equalizer.pde
+++ b/chp20_sound/exercise_20_10_graphic_equalizer/exercise_20_10_graphic_equalizer.pde
@@ -12,7 +12,7 @@ FFT fft;
void setup() {
size(514, 360);
- song = new SoundFile(this, "beat.mp3");
+ song = new SoundFile(this, "beat.wav");
song.loop();
fft = new FFT(this, 64);