Notion - Update docs

This commit is contained in:
shiffman 2024-02-27 15:17:15 +00:00 committed by GitHub
parent f4ffe38b5d
commit 84fa08a4a0
2 changed files with 0 additions and 4 deletions

View file

@ -918,18 +918,15 @@ position.add(velocity);</pre>
<p>Setting aside vectors for a second, take a look at the following code:</p>
<pre class="codesplit" data-code-language="javascript">let x = 0;
let y = 5;
x = x + y;</pre>
<p>This is probably what youre used to, yes? I give <code>x</code> a value of 0, add <code>y</code> to it, and now <code>x</code> is equal to 5. I could write similar code for adding two vectors:</p>
<pre class="codesplit" data-code-language="javascript">let v = createVector(0, 0);
let u = createVector(4, 5);
v.add(u);</pre>
<p>The vector <code>v</code> has the value of (0, 0), I add the vector <code>u</code> to it, and now <code>v</code> is equal to (4, 5). Makes sense, right?</p>
<p>Now consider this example:</p>
<pre class="codesplit" data-code-language="javascript">let x = 0;
let y = 5;
let z = x + y;</pre>
<p>I give <code>x</code> a value of 0, add <code>y</code> to it, and store the result in a new variable <code>z</code>. The value of <code>x</code> doesnt change here (neither does <code>y</code>)! This may seem like a trivial point, and one thats quite intuitive when it comes to mathematical operations with simple numbers. However, its not so obvious with mathematical operations using <code>p5.Vector</code> objects. Lets try to rewrite the example with vectors, based on what Ive covered of the <code>p5.Vector</code> class so far:</p>
<pre class="codesplit" data-code-language="javascript">let v = createVector(0, 0);

View file

@ -295,7 +295,6 @@ let ball = <span class="blank">Bodies</span>.<span class="blank">circle</span>(<
<div class="avoid-break">
<pre class="codesplit" data-code-language="javascript">// Store the canvas in a variable.
let canvas = createCanvas(640, 360);
// Configure the renderer.
let params = {
canvas: canvas.elt,