Skip to content

Commit 40895d6

Browse files
authored
Merge pull request #7709 from processing/fix/docs
2.0 beta 6 bug fixes
2 parents 0660e58 + 348b6fe commit 40895d6

File tree

10 files changed

+100
-93
lines changed

10 files changed

+100
-93
lines changed

docs/parameterData.json

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,6 @@
392392
[]
393393
]
394394
},
395-
"calculateOffset": {
396-
"overloads": [
397-
[]
398-
]
399-
},
400395
"createCanvas": {
401396
"overloads": [
402397
[
@@ -3094,37 +3089,6 @@
30943089
]
30953090
]
30963091
},
3097-
"update": {
3098-
"overloads": [
3099-
[]
3100-
]
3101-
},
3102-
"bindTexture": {
3103-
"overloads": [
3104-
[]
3105-
]
3106-
},
3107-
"unbindTexture": {
3108-
"overloads": [
3109-
[]
3110-
]
3111-
},
3112-
"setInterpolation": {
3113-
"overloads": [
3114-
[
3115-
"String",
3116-
"String"
3117-
]
3118-
]
3119-
},
3120-
"setWrapMode": {
3121-
"overloads": [
3122-
[
3123-
"String",
3124-
"String"
3125-
]
3126-
]
3127-
},
31283092
"remove": {
31293093
"overloads": [
31303094
[]
@@ -3267,13 +3231,6 @@
32673231
]
32683232
}
32693233
},
3270-
"p5.Renderer": {
3271-
"resize": {
3272-
"overloads": [
3273-
[]
3274-
]
3275-
}
3276-
},
32773234
"p5.Element": {
32783235
"remove": {
32793236
"overloads": [

src/accessibility/outputs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ function outputs(p5, fn){
540540

541541
//gets position of shape in the canvas
542542
fn._getPos = function (x, y) {
543-
const { x: transformedX, y: transformedY } = this.worldToScreen(new this.Vector(x, y));
543+
const { x: transformedX, y: transformedY } = this.worldToScreen(new p5.Vector(x, y));
544544
const canvasWidth = this.width;
545545
const canvasHeight = this.height;
546546
if (transformedX < 0.4 * canvasWidth) {
@@ -657,7 +657,7 @@ function outputs(p5, fn){
657657
];
658658
// Apply the inverse of the current transformations to the canvas corners
659659
const currentTransform = this._renderer.isP3D ?
660-
new DOMMatrix(this._renderer.states.uMVMatrix.mat4) :
660+
new DOMMatrix(this._renderer.uMVMatrix.mat4) :
661661
this.drawingContext.getTransform();
662662
const invertedTransform = currentTransform.inverse();
663663
const tc = canvasCorners.map(

src/core/p5.Renderer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,15 @@ function renderer(p5, fn){
367367
* @param {HTMLElement} elt DOM node that is wrapped
368368
* @param {p5} [pInst] pointer to p5 instance
369369
* @param {Boolean} [isMainCanvas] whether we're using it as main canvas
370+
* @private
370371
*/
371372
p5.Renderer = Renderer;
372373
}
373374

374375
/**
375376
* Helper fxn to measure ascent and descent.
376377
* Adapted from http://stackoverflow.com/a/25355178
378+
* @private
377379
*/
378380
function calculateOffset(object) {
379381
let currentLeft = 0,

src/dom/p5.Element.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,9 +1501,9 @@ class Element {
15011501
// For details, see https://github.com/processing/p5.js/issues/3087.
15021502
const eventPrependedFxn = function (event) {
15031503
this._pInst.mouseIsPressed = true;
1504-
this._pInst._activePointers.set(e.pointerId, e);
1504+
this._pInst._activePointers.set(event.pointerId, event);
15051505
this._pInst._setMouseButton(event);
1506-
this._pInst._updatePointerCoords(e);
1506+
this._pInst._updatePointerCoords(event);
15071507
// Pass along the return-value of the callback:
15081508
return fxn.call(this, event);
15091509
};

src/webgl/light.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ function light(p5, fn){
964964
* // Load an image and create a p5.Image object.
965965
* img = await loadImage('assets/outdoor_spheremap.jpg');
966966
*
967-
* createCanvas(100 ,100 ,WEBGL);
967+
* createCanvas(100, 100, WEBGL);
968968
*
969969
* describe('A sphere floating above a landscape. The surface of the sphere reflects the landscape. The full landscape is viewable in 3D as the user drags the mouse.');
970970
* }

src/webgl/p5.Camera.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,31 +2213,29 @@ class Camera {
22132213
*
22142214
* // Move the camera along its "local" axes
22152215
* // when the user presses certain keys.
2216-
* if (keyIsPressed === true) {
2217-
*
2218-
* // Move horizontally.
2219-
* if (keyCode === LEFT_ARROW) {
2220-
* cam.move(-1, 0, 0);
2221-
* }
2222-
* if (keyCode === RIGHT_ARROW) {
2223-
* cam.move(1, 0, 0);
2224-
* }
2225-
*
2226-
* // Move vertically.
2227-
* if (keyCode === UP_ARROW) {
2228-
* cam.move(0, -1, 0);
2229-
* }
2230-
* if (keyCode === DOWN_ARROW) {
2231-
* cam.move(0, 1, 0);
2232-
* }
2233-
*
2234-
* // Move in/out of the screen.
2235-
* if (key === 'i') {
2236-
* cam.move(0, 0, -1);
2237-
* }
2238-
* if (key === 'o') {
2239-
* cam.move(0, 0, 1);
2240-
* }
2216+
*
2217+
* // Move horizontally.
2218+
* if (keyIsDown(LEFT_ARROW)) {
2219+
* cam.move(-1, 0, 0);
2220+
* }
2221+
* if (keyIsDown(RIGHT_ARROW)) {
2222+
* cam.move(1, 0, 0);
2223+
* }
2224+
*
2225+
* // Move vertically.
2226+
* if (keyIsDown(UP_ARROW)) {
2227+
* cam.move(0, -1, 0);
2228+
* }
2229+
* if (keyIsDown(DOWN_ARROW)) {
2230+
* cam.move(0, 1, 0);
2231+
* }
2232+
*
2233+
* // Move in/out of the screen.
2234+
* if (keyIsDown('i')) {
2235+
* cam.move(0, 0, -1);
2236+
* }
2237+
* if (keyIsDown('o')) {
2238+
* cam.move(0, 0, 1);
22412239
* }
22422240
*
22432241
* // Draw the box.

src/webgl/p5.Shader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ class Shader {
526526
* <a href="#/p5.Graphics">p5.Graphics</a>, as in
527527
* `myShader.copyToContext(pg)`. The shader can also be copied from a
528528
* <a href="#/p5.Graphics">p5.Graphics</a> object to the main canvas using
529-
* the `window` variable, as in `myShader.copyToContext(window)`.
529+
* the `p5.instance` variable, as in `myShader.copyToContext(p5.instance)`.
530530
*
531531
* Note: A <a href="#/p5.Shader">p5.Shader</a> object created with
532532
* <a href="#/p5/createShader">createShader()</a>,
@@ -667,7 +667,7 @@ class Shader {
667667
* pg.shader(original);
668668
*
669669
* // Copy the original shader to the main canvas.
670-
* copied = original.copyToContext(window);
670+
* copied = original.copyToContext(p5.instance);
671671
*
672672
* // Apply the copied shader to the main canvas.
673673
* shader(copied);
@@ -843,7 +843,15 @@ class Shader {
843843

844844
for (const uniform of this.samplers) {
845845
let tex = uniform.texture;
846-
if (tex === undefined) {
846+
if (
847+
tex === undefined ||
848+
(
849+
false &&
850+
tex.isFramebufferTexture &&
851+
!tex.src.framebuffer.antialias &&
852+
tex.src.framebuffer === this._renderer.activeFramebuffer()
853+
)
854+
) {
847855
// user hasn't yet supplied a texture for this slot.
848856
// (or there may not be one--maybe just lighting),
849857
// so we supply a default texture instead.

src/webgl/p5.Texture.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ class Texture {
114114
* Initializes common texture parameters, creates a gl texture,
115115
* tries to upload the texture for the first time if data is
116116
* already available.
117-
* @private
118-
* @method init
119117
*/
120118
init (data) {
121119
const gl = this._renderer.GL;
@@ -172,7 +170,6 @@ class Texture {
172170
* easy to do so) and reuploads the texture if necessary. If it's not
173171
* possible or to expensive to do a calculation to determine wheter or
174172
* not the data has occurred, this method simply re-uploads the texture.
175-
* @method update
176173
*/
177174
update () {
178175
const data = this.src;
@@ -271,7 +268,6 @@ class Texture {
271268

272269
/**
273270
* Binds the texture to the appropriate GL target.
274-
* @method bindTexture
275271
*/
276272
bindTexture () {
277273
// bind texture using gl context + glTarget and
@@ -284,7 +280,6 @@ class Texture {
284280

285281
/**
286282
* Unbinds the texture from the appropriate GL target.
287-
* @method unbindTexture
288283
*/
289284
unbindTexture () {
290285
// unbind per above, disable texturing on glTarget
@@ -304,7 +299,6 @@ class Texture {
304299
* Sets how a texture is be interpolated when upscaled or downscaled.
305300
* Nearest filtering uses nearest neighbor scaling when interpolating
306301
* Linear filtering uses WebGL's linear scaling when interpolating
307-
* @method setInterpolation
308302
* @param {String} downScale Specifies the texture filtering when
309303
* textures are shrunk. Options are LINEAR or NEAREST
310304
* @param {String} upScale Specifies the texture filtering when
@@ -337,7 +331,6 @@ class Texture {
337331
* when their uv's go outside of the 0 - 1 range. There are three options:
338332
* CLAMP, REPEAT, and MIRROR. REPEAT & MIRROR are only available if the texture
339333
* is a power of two size (128, 256, 512, 1024, etc.).
340-
* @method setWrapMode
341334
* @param {String} wrapX Controls the horizontal texture wrapping behavior
342335
* @param {String} wrapY Controls the vertical texture wrapping behavior
343336
*/

test/unit/accessibility/outputs.js

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { mockP5, mockP5Prototype } from '../../js/mocks';
22
import outputs from '../../../src/accessibility/outputs';
33
import textOutput from '../../../src/accessibility/textOutput';
4+
import p5 from '../../../src/app.js';
45

56
// TODO: Is it possible to test this without a runtime?
67
suite('outputs', function() {
@@ -17,10 +18,36 @@ suite('outputs', function() {
1718
assert.typeOf(mockP5Prototype.textOutput, 'function');
1819
});
1920

21+
test('should not break for webgl', async function() {
22+
await new Promise((res) => {
23+
new p5((p) => {
24+
p.setup = function() {
25+
p.createCanvas(50, 50, p.WEBGL);
26+
p.textOutput();
27+
p.circle(0, 0, 20);
28+
res();
29+
};
30+
});
31+
});
32+
});
33+
34+
test('should not break for webgl', async function() {
35+
await new Promise((res) => {
36+
new p5((p) => {
37+
p.setup = function() {
38+
p.createCanvas(50, 50, p.WEBGL);
39+
p.gridOutput();
40+
p.circle(0, 0, 20);
41+
res();
42+
};
43+
});
44+
});
45+
});
46+
2047
let expected =
2148
'Your output is a, 100 by 100 pixels, white canvas containing the following shape:';
2249

23-
test.todo('should create output as fallback', function() {
50+
test('should create output as fallback', function() {
2451
return new Promise(function(resolve, reject) {
2552
let actual = '';
2653
new p5(function(p) {
@@ -46,7 +73,7 @@ suite('outputs', function() {
4673
});
4774
});
4875

49-
test.todo('should create output as label', function() {
76+
test('should create output as label', function() {
5077
return new Promise(function(resolve, reject) {
5178
let label = '';
5279
let fallback = '';
@@ -76,7 +103,7 @@ suite('outputs', function() {
76103
});
77104
});
78105

79-
test.todo('should create text output for arc()', function() {
106+
test('should create text output for arc()', function() {
80107
return new Promise(function(resolve, reject) {
81108
expected =
82109
'<li><a href="#myCanvasIDtextOutputshape0">red arc</a>, at middle, covering 31% of the canvas.</li>';
@@ -104,7 +131,7 @@ suite('outputs', function() {
104131
});
105132
});
106133

107-
test.todo('should create text output for ellipse()', function() {
134+
test('should create text output for ellipse()', function() {
108135
return new Promise(function(resolve, reject) {
109136
expected =
110137
'<li><a href="#myCanvasIDtextOutputshape0">green circle</a>, at middle, covering 24% of the canvas.</li>';
@@ -132,7 +159,7 @@ suite('outputs', function() {
132159
});
133160
});
134161

135-
test.todo('should create text output for triangle()', function() {
162+
test('should create text output for triangle()', function() {
136163
return new Promise(function(resolve, reject) {
137164
expected =
138165
'<li><a href="#myCanvasIDtextOutputshape0">green triangle</a>, at top left, covering 13% of the canvas.</li>';
@@ -170,7 +197,7 @@ suite('outputs', function() {
170197
let expected =
171198
'white canvas, 100 by 100 pixels, contains 1 shape: 1 square';
172199

173-
test.todo('should create output as fallback', function() {
200+
test('should create output as fallback', function() {
174201
return new Promise(function(resolve, reject) {
175202
let actual = '';
176203
new p5(function(p) {
@@ -196,7 +223,7 @@ suite('outputs', function() {
196223
});
197224
});
198225

199-
test.todo('should create output as label', function() {
226+
test('should create output as label', function() {
200227
return new Promise(function(resolve, reject) {
201228
let label = '';
202229
let fallback = '';
@@ -226,7 +253,7 @@ suite('outputs', function() {
226253
});
227254
});
228255

229-
test.todo('should create text output for quad()', function() {
256+
test('should create text output for quad()', function() {
230257
return new Promise(function(resolve, reject) {
231258
expected = 'red quadrilateral, location = top left, area = 45 %';
232259
new p5(function(p) {
@@ -253,7 +280,7 @@ suite('outputs', function() {
253280
});
254281
});
255282

256-
test.todo('should create text output for point()', function() {
283+
test('should create text output for point()', function() {
257284
return new Promise(function(resolve, reject) {
258285
expected = 'dark fuchsia point, location = bottom right';
259286
new p5(function(p) {
@@ -280,7 +307,7 @@ suite('outputs', function() {
280307
});
281308
});
282309

283-
test.todo('should create text output for triangle()', function() {
310+
test('should create text output for triangle()', function() {
284311
return new Promise(function(resolve, reject) {
285312
expected = 'green triangle, location = top left, area = 13 %';
286313
new p5(function(p) {

0 commit comments

Comments
 (0)