Skip to content

Commit 5fedd47

Browse files
committed
Merge remote-tracking branch 'processing/master'
2 parents 387bec6 + 23ed35b commit 5fedd47

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+292
-117
lines changed

lib/addons/p5.dom.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,8 @@
980980
// set width and height onload metadata
981981
elt.addEventListener('loadedmetadata', function() {
982982
elt.play();
983-
c.width = elt.width = elt.videoWidth;
984-
c.height = elt.height = elt.videoHeight;
983+
c.width = elt.videoWidth = elt.width;
984+
c.height = elt.videoHeight = elt.height;
985985
c.loadedmetadata = true;
986986
});
987987
return c;
@@ -1423,7 +1423,7 @@
14231423
* @example
14241424
* <div class='norender'><code>
14251425
* var div = createDiv('div');
1426-
* div.attribute("display", "none");
1426+
* div.style("display", "none");
14271427
* div.show(); // turns display to block
14281428
* </code></div>
14291429
*/
@@ -1766,7 +1766,11 @@
17661766
p5.MediaElement.prototype.get = function(x, y, w, h){
17671767
if (this.loadedmetadata) { // wait for metadata
17681768
return p5.Renderer2D.prototype.get.call(this, x, y, w, h);
1769-
} else return [0, 0, 0, 255];
1769+
} else if (!x) {
1770+
return new p5.Image(1, 1);
1771+
} else {
1772+
return [0, 0, 0, 255];
1773+
}
17701774
};
17711775
p5.MediaElement.prototype.set = function(x, y, imgOrCol){
17721776
if (this.loadedmetadata) { // wait for metadata

src/app.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,18 @@ require('./core/transform');
4646
require('./typography/attributes');
4747
require('./typography/loading_displaying');
4848

49-
require('./3d/p5.Renderer3D');
50-
require('./3d/p5.Geometry');
51-
require('./3d/p5.Renderer3D.Retained');
52-
require('./3d/p5.Renderer3D.Immediate');
53-
require('./3d/primitives');
54-
require('./3d/loading');
55-
require('./3d/p5.Matrix');
56-
require('./3d/material');
57-
require('./3d/light');
58-
require('./3d/shader');
59-
require('./3d/camera');
60-
require('./3d/interaction');
49+
require('./webgl/p5.RendererGL');
50+
require('./webgl/p5.Geometry');
51+
require('./webgl/p5.RendererGL.Retained');
52+
require('./webgl/p5.RendererGL.Immediate');
53+
require('./webgl/primitives');
54+
require('./webgl/loading');
55+
require('./webgl/p5.Matrix');
56+
require('./webgl/material');
57+
require('./webgl/light');
58+
require('./webgl/shader');
59+
require('./webgl/camera');
60+
require('./webgl/interaction');
6161

6262
/**
6363
* _globalInit

src/core/2d_primitives.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ p5.prototype.arc = function(x, y, w, h, start, stop, mode) {
123123
/**
124124
* Draws an ellipse (oval) to the screen. An ellipse with equal width and
125125
* height is a circle. By default, the first two parameters set the location,
126-
* and the third and fourth parameters set the shape's width and height. The
127-
* origin may be changed with the ellipseMode() function.
126+
* and the third and fourth parameters set the shape's width and height. If
127+
* no height is specified, the value of width is used for both the width and
128+
* height. The origin may be changed with the ellipseMode() function.
128129
*
129130
* @method ellipse
130131
* @param {Number} x x-coordinate of the ellipse.
131132
* @param {Number} y y-coordinate of the ellipse.
132133
* @param {Number} w width of the ellipse.
133-
* @param {Number} h height of the ellipse.
134+
* @param {Number} [h] height of the ellipse.
134135
* @return {p5} the p5 object
135136
* @example
136137
* <div>
@@ -145,14 +146,18 @@ p5.prototype.arc = function(x, y, w, h, start, stop, mode) {
145146
* @param {Number} y
146147
* @param {Number} z z-coordinate of the ellipse
147148
* @param {Number} w
148-
* @param {Number} h
149+
* @param {Number} [h]
149150
* @return {p5}
150151
*/
151152
p5.prototype.ellipse = function() {
152153
var args = new Array(arguments.length);
153154
for (var i = 0; i < args.length; ++i) {
154155
args[i] = arguments[i];
155156
}
157+
// Duplicate 3rd argument if onl 3 given.
158+
if (args.length === 3) {
159+
args.push(args[2]);
160+
}
156161
if(this._renderer.isP3D){
157162
// p5 supports negative width and heights for ellipses
158163
if (args[3] < 0){args[3] = Math.abs(args[3]);}
@@ -314,9 +319,17 @@ p5.prototype.point = function() {
314319
*/
315320
/**
316321
* @method quad
322+
* @param {Number} x1
323+
* @param {Number} y1
317324
* @param {Number} z1 the z-coordinate of the first point
325+
* @param {Number} x2
326+
* @param {Number} y2
318327
* @param {Number} z2 the z-coordinate of the second point
328+
* @param {Number} x3
329+
* @param {Number} y3
319330
* @param {Number} z3 the z-coordinate of the third point
331+
* @param {Number} x4
332+
* @param {Number} y4
320333
* @param {Number} z4 the z-coordinate of the fourth point
321334
* @return {p5} the p5 object
322335
*/
@@ -405,7 +418,15 @@ p5.prototype.quad = function() {
405418
*/
406419
/**
407420
* @method rect
421+
* @param {Number} x
422+
* @param {Number} y
408423
* @param {Number} z z-coordinate of the rectangle.
424+
* @param {Number} w
425+
* @param {Number} h
426+
* @param {Number} [tl]
427+
* @param {Number} [tr]
428+
* @param {Number} [br]
429+
* @param {Number} [bl]
409430
* @return {p5} the p5 object.
410431
*/
411432
p5.prototype.rect = function () {

src/core/core.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ var p5 = function(sketch, node, sync) {
335335
if (!this._loop ||
336336
time_since_last >= target_time_between_frames - epsilon) {
337337

338-
//mandatory update values(matrixs and stack) for 3d
338+
//mandatory update values(matrixs and stack)
339+
this.resetMatrix();
339340
if(this._renderer.isP3D){
340341
this._renderer._update();
341342
}

src/core/p5.Graphics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ p5.Graphics = function(w, h, renderer, pInst) {
3636
this._pixelDensity = pInst._pixelDensity;
3737

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

src/core/p5.Renderer2D.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,20 +213,19 @@ p5.Renderer2D.prototype.get = function(x, y, w, h) {
213213
var ctx = this._pInst || this;
214214

215215
var pd = ctx._pixelDensity;
216-
217-
this.loadPixels.call(ctx);
216+
ctx.loadPixels();
218217

219218
// round down to get integer numbers
220219
x = Math.floor(x);
221220
y = Math.floor(y);
222221

223222
if (w === 1 && h === 1){
224-
223+
var startPoint = pd*pd*4*(y*this.width+x);
225224
return [
226-
ctx.pixels[pd*4*(y*this.width+x)],
227-
ctx.pixels[pd*(4*(y*this.width+x)+1)],
228-
ctx.pixels[pd*(4*(y*this.width+x)+2)],
229-
ctx.pixels[pd*(4*(y*this.width+x)+3)]
225+
ctx.pixels[startPoint],
226+
ctx.pixels[startPoint+1],
227+
ctx.pixels[startPoint+2],
228+
ctx.pixels[startPoint+3]
230229
];
231230
} else {
232231
var sx = x * pd;
@@ -1106,7 +1105,7 @@ p5.Renderer2D.prototype.text = function (str, x, y, maxWidth, maxHeight) {
11061105
case constants.BOTTOM:
11071106
y += (maxHeight - totalHeight);
11081107
break;
1109-
case constants._CTX_MIDDLE:
1108+
case constants._CTX_MIDDLE: // CENTER?
11101109
y += (maxHeight - totalHeight) / 2;
11111110
break;
11121111
case constants.BASELINE:
@@ -1140,8 +1139,8 @@ p5.Renderer2D.prototype.text = function (str, x, y, maxWidth, maxHeight) {
11401139
}
11411140
}
11421141
else {
1143-
//offset to account for centering multiple lines of text
1144-
var offset = ((cars.length)*0.5-0.5)*p.textLeading();
1142+
// offset to account for vertically centering multiple lines of text
1143+
var offset = ((cars.length * 0.5) - 0.5) * p.textLeading(); // see #1410
11451144

11461145
for (jj = 0; jj < cars.length; jj++) {
11471146

src/core/rendering.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var p5 = require('./core');
88
var constants = require('./constants');
99
require('./p5.Graphics');
1010
require('./p5.Renderer2D');
11-
require('../3d/p5.Renderer3D');
11+
require('../webgl/p5.RendererGL');
1212
var defaultId = 'defaultCanvas0'; // this gets set again in createCanvas
1313

1414
/**
@@ -94,7 +94,7 @@ p5.prototype.createCanvas = function(w, h, renderer) {
9494
// Init our graphics renderer
9595
//webgl mode
9696
if (r === constants.WEBGL) {
97-
this._setProperty('_renderer', new p5.Renderer3D(c, this, true));
97+
this._setProperty('_renderer', new p5.RendererGL(c, this, true));
9898
this._isdefaultGraphics = true;
9999
}
100100
//P2D mode

src/core/structure.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ p5.prototype.redraw = function () {
283283
var userSetup = this.setup || window.setup;
284284
var userDraw = this.draw || window.draw;
285285
if (typeof userDraw === 'function') {
286-
this.resetMatrix.bind(this);
287286
if (typeof userSetup === 'undefined') {
288287
this.scale(this._pixelDensity, this._pixelDensity);
289288
}

src/io/p5.Table.js

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,17 +407,50 @@ p5.Table.prototype.matchRow = function(regexp, column) {
407407
};
408408

409409
/**
410-
* Finds the first row in the Table that matches the regular
411-
* expression provided, and returns a reference to that row.
412-
* Even if multiple rows are possible matches, only the first
413-
* matching row is returned. The column to search may be specified
414-
* by either its ID or title.
410+
* Finds the rows in the Table that match the regular expression provided,
411+
* and returns references to those rows. Returns an array, so for must be
412+
* used to iterate through all the rows, as shown in the example. The
413+
* column to search may be specified by either its ID or title.
415414
*
416415
* @method matchRows
417416
* @param {String} regexp The regular expression to match
418417
* @param {String|Number} [column] The column ID (number) or
419418
* title (string)
420419
* @return {Array} An Array of TableRow objects
420+
* @example
421+
* var table;
422+
*
423+
* function setup() {
424+
*
425+
* table = new p5.Table();
426+
*
427+
* table.addColumn('name');
428+
* table.addColumn('type');
429+
*
430+
* var newRow = table.addRow();
431+
* newRow.setString('name', 'Lion');
432+
* newRow.setString('type', 'Mammal');
433+
*
434+
* newRow = table.addRow();
435+
* newRow.setString('name', 'Snake');
436+
* newRow.setString('type', 'Reptile');
437+
*
438+
* newRow = table.addRow();
439+
* newRow.setString('name', 'Mosquito');
440+
* newRow.setString('type', 'Insect');
441+
*
442+
* newRow = table.addRow();
443+
* newRow.setString('name', 'Lizard');
444+
* newRow.setString('type', 'Reptile');
445+
*
446+
* var rows = table.matchRows('R.*', 'type');
447+
* for (var i = 0; i < rows.length; i++) {
448+
* println(rows[i].getString('name') + ': ' + rows[i].getString('type'));
449+
* }
450+
* }
451+
* // Sketch prints:
452+
* // Snake: Reptile
453+
* // Lizard: Reptile
421454
*/
422455
p5.Table.prototype.matchRows = function(regexp, column) {
423456
var ret = [];

src/math/p5.Vector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ p5.Vector.prototype.div = function (n) {
347347
* <div class="norender">
348348
* <code>
349349
* var v = createVector(20.0, 30.0, 40.0);
350-
* var m = v.mag(10);
350+
* var m = v.mag();
351351
* print(m); // Prints "53.85164807134504"
352352
* </code>
353353
* </div>

0 commit comments

Comments
 (0)