Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/core/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class p5 {
constructor(sketch, node) {
// Apply addon defined decorations
if(p5.decorations.size > 0){
decorateClass(p5, p5.decorations);
decorateClass(p5, p5.decorations, 'p5');
p5.decorations.clear();
}

Expand Down
2 changes: 2 additions & 0 deletions src/math/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import random from './random.js';
import trigonometry from './trigonometry.js';
import math from './math.js';
import vector from './p5.Vector.js';
import vectorValidation from './patch-vector.js';

export default function(p5){
p5.registerAddon(calculation);
Expand All @@ -12,4 +13,5 @@ export default function(p5){
p5.registerAddon(trigonometry);
p5.registerAddon(math);
p5.registerAddon(vector);
p5.registerAddon(vectorValidation);
}
19 changes: 3 additions & 16 deletions src/math/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function math(p5, fn) {
* <a href="#/p5.Vector">p5.Vector</a> class.
*
* @method createVector
* @param {...Number} x Zero or more numbers, representing each component of the vector.
* @param {...Number} x List of numbers representing each component of the vector.
* @return {p5.Vector} new <a href="#/p5.Vector">p5.Vector</a> object.
*
* @example
Expand Down Expand Up @@ -92,21 +92,8 @@ function math(p5, fn) {
* point(pos);
* }
*/
fn.createVector = function (x, y, z) {
if (arguments.length === 0) {
p5._friendlyError(
'In 1.x, createVector() was a shortcut for createVector(0, 0, 0). In 2.x, p5.js has vectors of any dimension, so you must provide your desired number of zeros. Use createVector(0, 0) for a 2D vector and createVector(0, 0, 0) for a 3D vector.'
);
}
if (this instanceof p5) {
return new p5.Vector(
this._fromRadians.bind(this),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done only in p5.Vector.

this._toRadians.bind(this),
...arguments
);
} else {
return new p5.Vector(x, y, z);
}
fn.createVector = function (...args) {
return new p5.Vector(...args);
};

/**
Expand Down
Loading
Loading