Skip to content

Commit

Permalink
Merge pull request #853 from nature-of-code/notion-update-docs
Browse files Browse the repository at this point in the history
chapter 0 layout
  • Loading branch information
shiffman authored Feb 26, 2024
2 parents b56bca3 + fa97544 commit 995bca1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion content/00_randomness.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,14 @@ <h3 id="example-01-a-traditional-random-walk">Example 0.1: A Traditional Random
<figcaption>Each time you see one of these example boxes in the book, it means that corresponding code is available in the p5.js web editor and on the book’s website. If you’re reading this book offline, you’ll see only a screenshot of the resulting canvas.</figcaption>
</figure>
</div>
<pre class="codesplit" data-code-language="javascript">//{!1} Then <code>draw()</code> loops forever and ever (until you quit).
<div class="avoid-break">
<pre class="codesplit" data-code-language="javascript">//{!1} Then <code>draw()</code> loops forever and ever (until you quit).
function draw() {
// Call functions on the walker.
walker.step();
walker.show();
}</pre>
</div>
<p>Since the background is drawn once in <code>setup()</code>, rather than clearing it continually each time through <code>draw()</code>, the trail of the random walk is visible in the canvas.</p>
<p>I could make a couple of adjustments to the random walker. For one, this <code>Walker</code> object’s steps are limited to four options: up, down, left, and right. But any given pixel in the canvas could have eight possible neighbors, including diagonals (see Figure 0.1). A ninth possibility, to stay in the same place, could also be an option.</p>
<figure>
Expand Down

0 comments on commit 995bca1

Please sign in to comment.