Skip to content

Commit 70ded6c

Browse files
author
Lauren McCarthy
committed
Merge branch 'master' of github.com:processing/p5.js
2 parents 0405832 + d7f82d1 commit 70ded6c

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

src/core/environment.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@ if (window.console && console.log) {
5858
console.log.apply(console, arguments);
5959
} else {
6060
var newArgs = JSON.parse(JSON.stringify(args));
61-
console.log(newArgs);
61+
if (JSON.stringify(newArgs)==='{}'){
62+
console.log(args);
63+
} else {
64+
console.log(newArgs);
65+
}
6266
}
6367
} catch(err) {
6468
console.log(args);

src/core/p5.Graphics.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ p5.Graphics = function(w, h, renderer, pInst) {
2525

2626
var r = renderer || constants.P2D;
2727

28-
var c = document.createElement('canvas');
28+
this.canvas = document.createElement('canvas');
2929
var node = this._userNode || document.body;
30-
node.appendChild(c);
30+
node.appendChild(this.canvas);
3131

32-
p5.Element.call(this, c, pInst, false);
32+
p5.Element.call(this, this.canvas, pInst, false);
3333
this._styles = [];
3434
this.width = w;
3535
this.height = h;
3636
this._pixelDensity = pInst._pixelDensity;
3737

3838
if (r === constants.WEBGL) {
39-
this._renderer = new p5.RendererGL(c, this, false);
39+
this._renderer = new p5.RendererGL(this.canvas, this, false);
4040
} else {
41-
this._renderer = new p5.Renderer2D(c, this, false);
41+
this._renderer = new p5.Renderer2D(this.canvas, this, false);
4242
}
4343

4444
this._renderer.resize(w, h);

src/math/p5.Vector.js

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,32 @@ p5.Vector.prototype.rotate = function (a) {
625625
return this;
626626
};
627627

628+
/**
629+
* Calculates and returns the angle (in radians) between two vectors.
630+
* @method angleBetween
631+
* @param {p5.Vector} the x, y, and z components of a p5.Vector
632+
* @return {Number} the angle between (in radians)
633+
* @example
634+
* <div class="norender">
635+
* <code>
636+
* var v1 = createVector(1, 0, 0);
637+
* var v2 = createVector(0, 1, 0);
638+
*
639+
* var angle = v1.angleBetween(v2);
640+
* // angle is PI/2
641+
* </code>
642+
* </div>
643+
*/
644+
p5.Vector.prototype.angleBetween = function (v) {
645+
var angle = Math.acos(this.dot(v) / (this.mag() * v.mag()));
646+
if (this.p5) {
647+
if (this.p5._angleMode === constants.DEGREES) {
648+
angle = polarGeometry.radiansToDegrees(angle);
649+
}
650+
}
651+
return angle;
652+
};
653+
628654
/**
629655
* Linear interpolate the vector to another vector
630656
*
@@ -1011,34 +1037,6 @@ p5.Vector.lerp = function (v1, v2, amt, target) {
10111037
return target;
10121038
};
10131039

1014-
/**
1015-
* Calculates and returns the angle (in radians) between two vectors.
1016-
* @method angleBetween
1017-
* @static
1018-
* @param {p5.Vector} v1 the x, y, and z components of a p5.Vector
1019-
* @param {p5.Vector} v2 the x, y, and z components of a p5.Vector
1020-
* @return {Number} the angle between (in radians)
1021-
* @example
1022-
* <div class="norender">
1023-
* <code>
1024-
* var v1 = createVector(1, 0, 0);
1025-
* var v2 = createVector(0, 1, 0);
1026-
*
1027-
* var angle = p5.Vector.angleBetween(v1, v2);
1028-
* // angle is PI/2
1029-
* </code>
1030-
* </div>
1031-
*/
1032-
p5.Vector.angleBetween = function (v1, v2) {
1033-
var angle = Math.acos(v1.dot(v2) / (v1.mag() * v2.mag()));
1034-
if (this.p5) {
1035-
if (this.p5._angleMode === constants.DEGREES) {
1036-
angle = polarGeometry.radiansToDegrees(angle);
1037-
}
1038-
}
1039-
return angle;
1040-
};
1041-
10421040
/**
10431041
* @static
10441042
*/

0 commit comments

Comments
 (0)