Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,181 changes: 184 additions & 997 deletions public/reference/data.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/search-indices/en.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/search-indices/es.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/search-indices/hi.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/search-indices/ko.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/search-indices/zh-Hans.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/content/reference/en/p5.Element/height.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: height
module: DOM
submodule: DOM
file: src/dom/p5.Element.js
description: A <code>Number</code> property that stores the element's height.
line: 2493
isConstructor: false
itemtype: property
class: p5.Element
type: Number
---


# height
15 changes: 15 additions & 0 deletions src/content/reference/en/p5.Element/width.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: width
module: DOM
submodule: DOM
file: src/dom/p5.Element.js
description: A <code>Number</code> property that stores the element's width.
line: 2493
isConstructor: false
itemtype: property
class: p5.Element
type: Number
---


# width
37 changes: 37 additions & 0 deletions src/content/reference/en/p5.MediaElement/src.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: src
module: DOM
submodule: DOM
file: src/dom/p5.MediaElement.js
description: Path to the media element's source as a string.
line: 1807
isConstructor: false
itemtype: property
example:
- |-
<div>
<code>
let beat;

function setup() {
createCanvas(100, 100);

// Create a p5.MediaElement using createAudio().
beat = createAudio('/assets/beat.mp3');

describe('The text "https://p5js.org/reference//assets/beat.mp3" written in black on a gray background.');
}

function draw() {
background(200);

textWrap(CHAR);
text(beat.src, 10, 10, 80, 80);
}
</code>
</div>
class: p5.MediaElement
---


# src
170 changes: 151 additions & 19 deletions src/content/reference/en/p5.Vector/add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,163 @@ title: add
module: Math
submodule: ''
file: src/math/p5.Vector.js
description: ''
line: 3342
description: >
<p>Adds to a vector's components.</p>

<p><code>add()</code> can use separate numbers, as in <code>v.add(1, 2,
3)</code>,

another <a href="/reference/p5/p5.Vector">p5.Vector</a> object, as in
<code>v.add(v2)</code>, or

an array of numbers, as in <code>v.add([1, 2, 3])</code>.</p>

<p>If a value isn't provided for a component, it won't change. For

example, <code>v.add(4, 5)</code> adds 4 to <code>v.x</code>, 5 to
<code>v.y</code>, and 0 to <code>v.z</code>.

Calling <code>add()</code> with no arguments, as in <code>v.add()</code>, has
no effect.</p>

<p>This method supports N-dimensional vectors.</p>

<p>The static version of <code>add()</code>, as in <code>p5.Vector.add(v2,
v1)</code>, returns a new

<a href="/reference/p5/p5.Vector">p5.Vector</a> object and doesn't change the

originals.</p>
line: 517
isConstructor: false
itemtype: method
example: []
example:
- |-
<div>
<code>
function setup() {
createCanvas(100, 100);

background(200);

// Style the points.
strokeWeight(5);

// Top left.
let pos = createVector(25, 25);
point(pos);

// Top right.
// Add numbers.
pos.add(50, 0);
point(pos);

// Bottom right.
// Add a p5.Vector.
let p2 = createVector(0, 50);
pos.add(p2);
point(pos);

// Bottom left.
// Add an array.
let arr = [-50, 0];
pos.add(arr);
point(pos);

describe('Four black dots arranged in a square on a gray background.');
}
</code>
</div>

<div>
<code>
function setup() {
createCanvas(100, 100);

background(200);

// Top left.
let p1 = createVector(25, 25);

// Center.
let p2 = createVector(50, 50);

// Bottom right.
// Add p1 and p2.
let p3 = p5.Vector.add(p1, p2);

// Draw the points.
strokeWeight(5);
point(p1);
point(p2);
point(p3);

describe('Three black dots in a diagonal line from top left to bottom right.');
}
</code>
</div>

<div>
<code>
function setup() {
createCanvas(100, 100);

describe('Three arrows drawn on a gray square. A red arrow extends from the top left corner to the center. A blue arrow extends from the tip of the red arrow. A purple arrow extends from the origin to the tip of the blue arrow.');
}

function draw() {
background(200);

let origin = createVector(0, 0);

// Draw the red arrow.
let v1 = createVector(50, 50);
drawArrow(origin, v1, 'red');

// Draw the blue arrow.
let v2 = createVector(-30, 20);
drawArrow(v1, v2, 'blue');

// Purple arrow.
let v3 = p5.Vector.add(v1, v2);
drawArrow(origin, v3, 'purple');
}

// Draws an arrow between two vectors.
function drawArrow(base, vec, myColor) {
push();
stroke(myColor);
strokeWeight(3);
fill(myColor);
translate(base.x, base.y);
line(0, 0, vec.x, vec.y);
rotate(vec.heading());
let arrowSize = 7;
translate(vec.mag() - arrowSize, 0);
triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);
pop();
}
</code>
</div>
class: p5.Vector
return:
description: resulting <a href="#/p5.Vector">p5.Vector</a>.
type: p5.Vector
overloads:
- params:
- name: v1
description: A <a href="#/p5.Vector">p5.Vector</a> to add
type: p5.Vector
- name: v2
description: A <a href="#/p5.Vector">p5.Vector</a> to add
type: p5.Vector
- name: target
description: vector to receive the result.
- name: x
description: x component of the vector to be added or an array of components.
type: Number|Array
- name: 'y'
description: y component of the vector to be added.
optional: 1
type: p5.Vector
return:
description: resulting <a href="#/p5.Vector">p5.Vector</a>.
type: p5.Vector
chainable: false
type: Number
- name: z
description: z component of the vector to be added.
optional: 1
type: Number
- params:
- name: value
description: The vector to add
type: 'p5.Vector|Number[]'
chainable: true
---


Expand Down
Loading