Skip to content

Commit c25e4c7

Browse files
author
lauren mccarthy
committed
adding _styles storage to p5.graphics elements closes #387
1 parent b0459ed commit c25e4c7

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

lib/p5.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! p5.js v0.3.8 October 04, 2014 */
1+
/*! p5.js v0.3.8 October 07, 2014 */
22
var shim = function (require) {
33
window.requestDraw = function () {
44
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
@@ -98,7 +98,7 @@ var core = function (require, shim, constants) {
9898
this._updateInterval = 0;
9999
this._isGlobal = false;
100100
this._loop = true;
101-
this.styles = [];
101+
this._styles = [];
102102
this._defaultCanvasSize = {
103103
width: 100,
104104
height: 100
@@ -597,6 +597,7 @@ var p5Graphics = function (require, core, constants) {
597597
this._pInst._setProperty('height', this.height);
598598
} else {
599599
this.canvas.style.display = 'none';
600+
this._styles = [];
600601
}
601602
};
602603
p5.Graphics.prototype = Object.create(p5.Element.prototype);
@@ -1807,7 +1808,7 @@ var dataconversion = function (require, core) {
18071808
radix = radix | 10;
18081809
return parseInt(n, radix);
18091810
} else if (typeof n === 'number') {
1810-
return Math.floor(n);
1811+
return n | 0;
18111812
} else if (typeof n === 'boolean') {
18121813
return n ? 1 : 0;
18131814
} else if (n instanceof Array) {
@@ -4442,7 +4443,7 @@ var structure = function (require, core) {
44424443
};
44434444
p5.prototype.push = function () {
44444445
this.drawingContext.save();
4445-
this.styles.push({
4446+
this._styles.push({
44464447
doStroke: this._doStroke,
44474448
doFill: this._doFill,
44484449
tint: this._tint,
@@ -4458,7 +4459,7 @@ var structure = function (require, core) {
44584459
};
44594460
p5.prototype.pop = function () {
44604461
this.drawingContext.restore();
4461-
var lastS = this.styles.pop();
4462+
var lastS = this._styles.pop();
44624463
this._doStroke = lastS.doStroke;
44634464
this._doFill = lastS.doFill;
44644465
this._tint = lastS.tint;

lib/p5.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ define(function (require) {
146146
this._updateInterval = 0;
147147
this._isGlobal = false;
148148
this._loop = true;
149-
this.styles = [];
149+
this._styles = [];
150150
this._defaultCanvasSize = {
151151
width: 100,
152152
height: 100

src/data/conversion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ define(function (require) {
5353
radix = radix | 10;
5454
return parseInt(n, radix);
5555
} else if (typeof n === 'number') {
56-
return Math.floor(n);
56+
return n | 0;
5757
} else if (typeof n === 'boolean') {
5858
return n ? 1 : 0;
5959
} else if (n instanceof Array) {

src/objects/p5.Graphics.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ define(function(require) {
5454
this._pInst._setProperty('height', this.height);
5555
} else { // hide if offscreen buffer by default
5656
this.canvas.style.display = 'none';
57+
this._styles = []; // non-main elt styles stored in p5.Graphics
5758
}
5859
};
5960

src/structure/structure.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ define(function (require) {
102102
*/
103103
p5.prototype.push = function () {
104104
this.drawingContext.save();
105-
this.styles.push({
105+
this._styles.push({
106106
doStroke: this._doStroke,
107107
doFill: this._doFill,
108108
tint: this._tint,
@@ -170,7 +170,7 @@ define(function (require) {
170170
*/
171171
p5.prototype.pop = function () {
172172
this.drawingContext.restore();
173-
var lastS = this.styles.pop();
173+
var lastS = this._styles.pop();
174174
this._doStroke = lastS.doStroke;
175175
this._doFill = lastS.doFill;
176176
this._tint = lastS.tint;

0 commit comments

Comments
 (0)