You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/00_5_introduction.html
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ <h2 id="what-do-you-need-to-know">What Do You Need to Know?</h2>
20
20
<p>I should also point out that experience with object-oriented programming is fairly critical. I’ll review some of the basics in Chapter 0, but if classes and objects are unfamiliar to you, I suggest watching <ahref="https://thecodingtrain.com/oop">my p5.js and Processing object-oriented video tutorials, both also available at the Coding Train</a>.</p>
21
21
<h2id="how-are-you-reading-this-book">How Are You Reading This Book?</h2>
22
22
<p>Are you reading this book on a Kindle? Printed paper? On your laptop in PDF form? On a tablet showing an animated HTML5 version? Are you strapped to a chair, absorbing the content directly into your brain via a series of electrodes, tubes, and cartridges?</p>
23
-
<p>My dream has always been to write this book in one single format (in this case, a collection of Notion documents) and then, after pressing a magic button (<code>npm run build</code>), out comes the book in any and all formats you might want—PDF, HTML5, printed hard copy, Kindle, and so on. This was largely made possible by the <ahref="https://github.com/magicbookproject">Magic Book project</a>, an open source framework for self-publishing originally developed at ITP by Rune Madsen and Steve Klise. Everything has been designed and styled using CSS—no manual typesetting or layout.</p>
23
+
<p>My dream has always been to write this book in one single format (in this case, a collection of Notion documents) and then, after pressing a magic button (<code>npm run build</code>), out comes the book in any and all formats you might want—PDF, HTML5, printed hard copy, Kindle, and so on. This was largely made possible by the <ahref="https://github.com/magicbookproject">Magic Book project</a>, which is an open source framework for self-publishing originally developed at ITP by Rune Madsen and Steve Klise. Everything has been designed and styled using CSS—no manual typesetting or layout.</p>
24
24
<p>The reality of putting this book together isn’t quite so clean as that, and the story of how it happened is long. If you’re interested in learning more, make sure to read the book’s acknowledgments, and then go hire the people I’ve thanked to help you publish a book! <ahref="https://github.com/nature-of-code">I’ll also include more details in the associated GitHub repository</a>.</p>
25
25
<p>The bottom line is that no matter what format you’re reading it in, the material is all the same. The only difference will be in how you experience the code examples—more on that in <ahref="#how-to-read-the-code">“How to Read the Code”</a>.</p>
Copy file name to clipboardExpand all lines: content/01_vectors.html
+2-5Lines changed: 2 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -658,13 +658,10 @@ <h3 id="example-16-normalizing-a-vector">Example 1.6: Normalizing a Vector</h3>
658
658
659
659
translate(width / 2, height / 2);
660
660
stroke(200);
661
-
strokeWeight(2);
662
661
line(0, 0, mouse.x, mouse.y);
663
-
664
-
// In this example, after the vector is normalized, it’s multiplied by 50. Note that no matter where the mouse is, the vector always has the same length (50) because of the normalization process.
662
+
//{!2} In this example, after the vector is normalized, it’s multiplied by 50. Note that no matter where the mouse is, the vector always has the same length (50) because of the normalization process.
665
663
mouse.normalize();
666
664
mouse.mult(50);
667
-
668
665
stroke(0);
669
666
strokeWeight(8);
670
667
line(0, 0, mouse.x, mouse.y);
@@ -713,7 +710,7 @@ <h2 id="motion-with-vectors">Motion with Vectors</h2>
713
710
<p>The <code>Mover</code> class also needs a function that determines what the object should do when it reaches the edge of the canvas. For now, I’ll do something simple and have it wrap around the edges:</p>
Copy file name to clipboardExpand all lines: content/03_oscillation.html
+2-7Lines changed: 2 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -269,9 +269,8 @@ <h2 id="pointing-in-the-direction-of-movement">Pointing in the Direction of Move
269
269
</table>
270
270
<p>Now that I have the formula, let’s see where it should go in the <code>Mover</code> class’s <code>show()</code> method to make the mover (now drawn as a rectangle) point in its direction of motion. Note that in p5.js, the function for inverse tangent is <code>atan()</code>:</p>
<p>Now that I have the algorithm for computing the spring force, the question remains: What OOP structure should I use? This is one of those situations that has no one correct answer. Several possibilities exist, and the one I choose depends on my goals and personal coding style.</p>
0 commit comments