Giter VIP home page Giter VIP logo

learningprocessing's Introduction

Learning Processing

This repository includes all of the examples for the book Learning Processing, a beginners guide to programming images, animation and interaction.

The book was written in 2008 and all of the examples were built for Processing 1.0. I am in the process of updating everything for Processing 2.0 and welcome any issues and pull requests.

learningprocessing's People

Contributors

benswift avatar ghufransyed avatar multimentha avatar scottgarner avatar shiffman avatar ybakos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learningprocessing's Issues

enhanced loop in chapter 9?

Should I include:

for (Ball b: balls) {
  b.display();
}

in addition to

for (int i = 0; i < balls.length; i++) {
  balls[i].display();
}

Perhaps I'll wait for Chapter 23 and ArrayLists to mention the enhanced loop? Or should I redo all examples and use it throughout?

code style standards

Check for consistency:

  • two space indentation

Also:

  • arguments separated by commas with no spaces or one space after comma?
  • spaces between operators or no?
line(x + y, 100, 50, 100);
line(x+y,100,50,100);

Decisions, decisions. . .

mention IntList, FloatList, StringList in chapter on ArrayLists (with possible reference in data chapter too.)

"IntList is faster than ArrayList (since ArrayList uses Integer objects) and less fussy than typing/explaining ArrayList. It also lets you sort things directly (ascending/descending) instead of needing some odd Collections thing… Basically any time you'd want to use ArrayList, you're better off w/ IntList. As compared to int[], it's less housekeeping since you're not keeping track of the length of the array and that sort of thing."

gravity

"p. 159 You might want to explain the immensely important line “y=height” which keeps the ball from jiggling on the line by resetting it to be exactly at the line itself. This turns out to be a big problem in this kind of algorithm"

example 5.7

This code does not correct for stepping over the boundaries.

When the code reaches the first boundary (c1 == 255.1, c2 == -0.1), both c1dir and c2dir are negated, but c1 and c2 retain the values 255.1 and -0.1 which will be passed to fill() on the next call to draw(). Similarly for each colour variable heading in the other direction.

Including "c1 = c1 + c1dir;" in the first conditional will repeat the boundary value, so a nice crisp bounce is produced with "c1 = c1 + 2 * c1dir;" or equivalent code.

I might also suggest using variable names other than c1dir and c2dir since they are rates of change, not merely (or perhaps not even) "directions".

A similar problem exists in the "bouncing ball" (Example 5-6) code, but is arguably less "critical" (the ball doesn't "bounce" until the centre passes the edge anyway). The bouncing ball problem is one that I still find tricky - for example, a bouncing ball under "gravity" that eventually comes to rest, and that looks good, is not so easy!

default drawing settings are not restored when the loop resets

from a reader: "I don't know if, when you introduce the draw function, there was anything about bugs that can show up from changing stroke settings toward the end of repeated code. It took me a while to troubleshoot a student using noStroke near the end of a figure that, when he put it into draw, changed dramatically. Maybe a warning that the default drawing settings are not restored when the loop resets."

All chapter x-refs

While everyhing needs to be checked, these chapters have a ton of changes and need to be examined closely.

  • chapter 18 - data
  • chapter 20 - sound

example 6.3 screenshot

The book I'm referring to is "Learning Processing" A Beginner's Guide to Programming Images, Animation, and Interaction. In lesson 2, chapter 6, example 6.3 the code is correct but the illustration is not. It looks like it illustrates:
size(200,200);
background(255);
int y = 60;
int x = 50;
int spacing = 10;
int len = 20;
int endLegs = 150;
stroke(0);
while (x <= endLegs) {
line (x,y,x, y + len);
x = x + spacing;
}

rather than

size(200,200);
background(255);
int y = 80;
int x = 50;
int spacing = 10;
int len = 20;
int endLegs = 150;
stroke(0);
while (x <= endLegs) {
line (x,y,x, y + len);
x = x + spacing;
}

In other words, int y = 80 should be int y = 60 to match the illustration (fig 6.3).

Chapter 12 Libraries

Holding off on Chapter 12 now as the explanation will need to be updated according to how the contribution manager ends up.

change in spectrum analysis

fft = new FFT(this,512);
fft.input(song);
fft.analyze();
for (int i = 0; i < fft.size(); i++) {
  stroke(50);
  float y = map(fft.spectrum[i], 0, 1, height * 0.75, 0);
  line(i, height * 0.75, i, y);
}

18.6, 19.1 Asynchronous vs synchronous requests

Despite the time spent on the client / server is indeed asynchronous (a short simple request may invoke a long server-side response), the use of asynchronous request is incorrectly used in 18.6 and 19.1. You also address blocking, which really means "synchronous," so this is important to keep aligned.

18.6
_a request ... is asynchronous, meaning ...
This should be is synchronous, meaning your program waits for a response from the server before continuing.

19.1
The above process is known as an asynchronous request and response
This should be The above process is known as a synchronous request and response, because the client waits until the server responds before sending another message.

imagine if you were to use asynchronous...
This should be imagine if you were to use synchronous...

...a different type of connection is used, a synchronous one...
This should be ...a different type of connection is used, an asynchronous one...

Synchronous communication is also necessary for live...
This should be Asynchronous communication is also necessary for live...

fig. 19.1 Left diagram should be Synchronous request.

I think you can essentially swap your use of synchronous/asynchronous without causing the need for any additional elaboration.

chapter 10 reachedBottom

I have a reacheBottom() method but it's never used (although it's referred to in the exercise at the end of the chapter)

  // Check if it hits the bottom
  boolean reachedBottom() { <span class="callout-bubble">In addition, we have a function that determines if the drop leaves the window.</span>
    // If we go a little past the bottom
    if (y &gt; height + r*4) {
      return true;
    } else {
      return false;
    }
  }

Take out or explain?

Learning Processing - page 93

There is a mismatch between code and description on page 93.

The code says "background(255);" and the text below reads "Draw a black background" where it should read "Draw a white background".

Section on map() in Chapter 13

In between noise and trig

  • exercise will be to use map() for noise
  • then use it in trig examples
  • also use map() in final 2d array of cell objects example

starting rewrite for 2e!

Tracking my first pass over chapters. Specific chapter related issues will be filed separately.

  • acknowledgments
  • intro
  • chp 1 pixels
  • chp 2 Processing
  • chp 3 interaction
  • chp 4 variables
  • chp 5 conditionals
  • chp 6 loops
  • chp 7 functions
  • chp 8 objects
  • chp 9 arrays
  • chp 10 algorithms
  • chp 11 debugging
  • chp 12 libraries
  • chp 13 mathematics
  • chp 14 3D (PShape, PShader mentions?)
  • chp 15 images
  • chp 16 video (GStreamer, not quicktime)
  • chp 17 text
  • chp 18 data (Table, XML, JSON?)
  • chp 19 data streams
  • chp 20 sound (new library!)
  • chp 21 exporting (no more applets, JS discussion)
  • chp 22 advanced OOP
  • chp 23 Java (generics?)
  • appendix

Sound chapter 20

Using the new processing.sound core library by @wirsing. My tentative plan is:

  • basic sound file playback (music, sound effect)
  • playback manipulation (amplitude, rate, pan)
  • simple sound synthesis (a wave?)
  • audio input, volume tied to ellipse size
  • audio input, thresholding (trigger event on clap)
  • audio input, spectrum???

chapter 1

I read Chapter 1 the Learning Processing book, and I think there
may be additional errata for Section 1.1, page 4, on Fig 1.2:

You say to think of the "verb" as a "function" and the "arguments" as
"objects" and in the figure you have bubbles labeled "object"
pointing at the arguments and a bubble labeled "verb" pointing at the
verb. Is that bubble meant to be labeled "function"?

examples 15.8 and 15.9

img.loadPixels(); is there, but it is on the wrong line (same line as the comment) and thus not executed. Same thing for 15.8 btw.

7.6, 8.7 pass by value/copy/reference

There are some problems (inaccuracies) with the way pass-by-value and pass-by-reference are presented in the text. First, I recognize that this is a topic that is "more advanced" than the student should be, so I understand the approach of simplifying the concepts.

7.6
but will not be the case when we learn about objects in the next chapter.
This is incorrect because chapter 8 is incorrect. Objects, and all things in Java, are pass by value. The fact that an object variable is a reference to an object does not change the fact that a copy of the reference is passed to functions. I would simplify this last phrase as but is not quite the same with objects, which we will learn about in the next chapter.

8.7
With objects, this is not the case, and the result is a bit more intuitive. If changes are made to an object after it is passed into a function, those changes will affect that object used anywhere else throughout the sketch. This is known as pass by reference since instead of a copy, a reference to the actual object itself is passed into the function.
This paragraph is wrong, but I feel like there are only two solutions: either simplify this in the main copy as just With objects, this is not the case: if changes are made to an object after it is passed into a function, those changes will affect that object used anywhere else throughout the sketch and provide details about object variables being references in the sidebar; or delve into how objects are represented in memory and so on. One of the best illustrations for this concept is in the Head First Java book. However, in keeping with the spirit of your book, I would simplify this concept, removing the incorrect statement, and perhaps address the "why" in a gray sidebar box like you did in a few other places.

"In this chapter"

Need to double check the in this chapter lists at the start of each chapter, in particular for the ones that have changed majorly

  • Video
  • Data
  • Sound
  • Exporting

and all others

mention images earlier?

I don't think I would cover it earlier but perhaps alluding / hinting to images would be helpful.

"The book has extensive about image manipulation. However I miss images in the first chapters. I found that students like to draw the Zoog, but they are also curious to work with real images. Maybe parts of the Zoog can be a transparant PNG and an SVG. In this way students exercise with images as well. However this could also introduce to many new concepts in the first chapters."

data chapter

needs a major update using current technologies and 2.0 API

chapter 6

not sure about this one:

On page 91, Example 6-7, the code in the first box should (only) be:

void setup() {
size(200,200);
}

IOW, the code:

void draw() {
background(0);

should be moved out of the first box and placed at the top of the second box.

Naming convention

Need a better naming convention --

LP_1_10_Description.pde

or something

images chapter

I stumbled a little with the section on PImage. In a future edition, I would suggest adding that the filename extensions, ".jpg", ".png" etc. are required. When I tried without them, I got a bunch of error messages and it took me awhile to realize that without the extensions, it doesn't work. I skimmed back over the chapter and didn't read mention of this (perhaps I missed it).

In the example on using a for loop to load images into an array, top of p. 261, I wondered about the sample filenames there "animal1.jpg", "animal2,jpg". Since in the for loop the first time through, i = 0, if there is no "animal0.jpg" won't you get an error?

Chapter 11 Debugger

At the end of chapter 11 mention something about the new 3.0 debugger, possibly with a screenshot.

Project and Zoog

Teaching at ITP, I've found that continuing to play with an elaborate design throughout the first half of the book doesn't necessarily work well and I usually have students start over with something simpler after creating their "Zoog." But maybe in the book, this works well and I should keep it. Something to consider.

Exercise 17-10

Need to publish solution

Create a sketch that starts with characters randomly scattered (and rotated). Have them slowly move back toward their “home” location. Use an object-oriented approach as seen in Example 17-6.1

One way to solve this is to use interpolation. Interpolation refers to the process of calculating values in between two given pieces of data. In this exercise, we want to know the in-between x locations (and y locations) from the random starting point to the target location in the String. One interpolation method is to simply take the average. Think of it as walking to a wall by always taking a step halfway.
x = (x + targetX)/2; y = (y + targetY)/2;
Another possibility is to simply go 10% of the way there.
x = 0.9_x + 0.l_targetX;
y = 0.9_y + 0.l_targetY;
Processing’s lerp( ) function will do interpolation for you. Visit the reference page for more information: http://processing.org/reference/lerp_.html.
Consider making your sketch interactive. Can you push the letters around using the mouse?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.