Skip to content

Commit

Permalink
merging little size() change
Browse files Browse the repository at this point in the history
  • Loading branch information
shiffman committed Mar 2, 2014
2 parents 38b836c + e737866 commit 3d2046a
Show file tree
Hide file tree
Showing 21 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ This is the repository for example [Processing](http://processing.org) code from

### Other
* [Clojure / Quil](https://github.com/sjl/The-Nature-of-Code-Examples)
* [More Clojure / Quil](https://github.com/mudphone/natureofclojure)


Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Example 1-4: Vector multiplication

void setup() {
size(800,200);
size(640,360);
smooth();
}

Expand Down
2 changes: 1 addition & 1 deletion chp1_vectors/NOC_1_7_motion101/NOC_1_7_motion101.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Mover mover;

void setup() {
size(800,200);
size(640,360);
mover = new Mover();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Attractor a;
float g = 1;

void setup() {
size(800,200);
size(640,360);
a = new Attractor();
for (int i = 0; i < movers.length; i++) {
movers[i] = new Mover(random(4,12),random(width),random(height));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void draw() {
background(255);




for (int i = 0; i < movers.length; i++) {
for (int j = 0; j < movers.length; j++) {
if (i != j) {
Expand All @@ -26,7 +28,6 @@ void draw() {
}

movers[i].boundaries();

movers[i].update();
movers[i].display();
}
Expand Down
6 changes: 3 additions & 3 deletions chp2_forces/NOC_2_6_attraction/Attractor.pde
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class Attractor {
PVector attract(Mover m) {
PVector force = PVector.sub(location,m.location); // Calculate direction of force
float d = force.mag(); // Distance between objects
d = constrain(d,5.0,25.0); // Limiting the distance to eliminate "extreme" results for very close or very far objects
d = constrain(d,5.0,25.0); // Limiting the distance to eliminate "extreme" results for very close or very far objects
force.normalize(); // Normalize vector (distance doesn't matter here, we just want this vector for direction)
float strength = (G * mass * m.mass) / (d * d); // Calculate gravitional force magnitude
force.mult(strength); // Get force vector --> magnitude * direction
float strength = (G * mass * m.mass) / (d * d); // Calculate gravitional force magnitude
force.mult(strength); // Get force vector --> magnitude * direction
return force;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Mover[] movers = new Mover[20];
Attractor a;

void setup() {
size(800,200);
size(640,360);
background(255);
for (int i = 0; i < movers.length; i++) {
movers[i] = new Mover(random(0.1,2),random(width),random(height));
Expand Down
2 changes: 1 addition & 1 deletion chp3_oscillation/NOC_3_03_pointing_velocity/Mover.pde
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Mover {
}

void display() {
float theta = velocity.heading2D();
float theta = velocity.heading();

stroke(0);
strokeWeight(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Mover mover;

void setup() {
size(800,200);
size(640,360);
mover = new Mover();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
float r;
float theta;


void setup() {
size(800, 200);
size(640, 360);
// Initialize all values
r = height * 0.45;
theta = 0;
Expand All @@ -39,6 +38,7 @@ void draw() {

// Increase the angle over time
theta += 0.02;



}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// http://natureofcode.com

void setup() {
size(800,200);
size(640,360);
}

void draw() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Oscillator[] oscillators = new Oscillator[10];

void setup() {
size(800,200);
size(640,360);
smooth();
// Initialize all objects
for (int i = 0; i < oscillators.length; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
float angle = 0;
float angleVel = 0.1;

size(800,200);
size(640,360);
background(255);
stroke(0);
strokeWeight(2);
Expand Down
3 changes: 1 addition & 2 deletions chp3_oscillation/NOC_3_09_wave/NOC_3_09_wave.pde
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ float startAngle = 0;
float angleVel = 0.23;

void setup() {
size(800,200);
smooth();
size(640,360);
}

void draw() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Pendulum p;

void setup() {
size(800,200);
size(640,360);
// Make a new Pendulum with an origin location and armlength
p = new Pendulum(new PVector(width/2,0),175);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Pendulum p;

void setup() {
size(800,200);
size(640,360);
// Make a new Pendulum with an origin location and armlength
p = new Pendulum(new PVector(width/2,0),175);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Particle p;

void setup() {
size(800,200);
size(640,360);
p = new Particle(new PVector(width/2,20));
background(255);
smooth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Mover[] movers = new Mover[25];
Attractor a;

void setup() {
size(800,200);
size(640,360);
box2d = new Box2DProcessing(this);
box2d.createWorld();
// No global gravity force
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Population population;
Button button;

void setup() {
size(800,200);
size(640,360);
colorMode(RGB,1.0);
int popmax = 10;
float mutationRate = 0.05; // A pretty high mutation rate here, our population is rather small we need to enforce variety
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Walker w;

void setup() {
size(800,200);
size(640,360);
// Create a walker object
w = new Walker();
background(255);
Expand Down
2 changes: 1 addition & 1 deletion introduction/Noise2D/Noise2D.pde
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
float increment = 0.02;

void setup() {
size(800,200);
size(640,360);
noLoop();
}

Expand Down

0 comments on commit 3d2046a

Please sign in to comment.