diff --git a/.all-contributorsrc b/.all-contributorsrc index 68bff60a05..b0f4165cfb 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -6395,6 +6395,24 @@ "contributions": [ "doc" ] + }, + { + "login": "zs-5", + "name": "ℤ", + "avatar_url": "https://avatars.githubusercontent.com/u/177980470?v=4", + "profile": "https://github.com/zs-5", + "contributions": [ + "doc" + ] + }, + { + "login": "Dhanush111", + "name": "dhanush", + "avatar_url": "https://avatars.githubusercontent.com/u/51503598?v=4", + "profile": "https://github.com/Dhanush111", + "contributions": [ + "doc" + ] } ], "repoType": "github", diff --git a/README.md b/README.md index 942b5cb6c1..0f0827f282 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [](https://www.npmjs.com/package/p5) -[](#contributors) +[](#contributors) [](https://www.npmjs.com/package/p5) # [p5.js](https://p5js.org) @@ -1072,6 +1072,8 @@ We recognize all types of contributions. This project follows the [all-contribut
+ * let style = document.createElement('style');
+ * style.innerHTML = `
+ * .p5-radio label {
+ * display: flex;
+ * align-items: center;
+ * }
+ * .p5-radio input {
+ * margin-right: 5px;
+ * }
+ * `;
+ * document.head.appendChild(style);
+ *
* let myRadio;
*
* function setup() {
@@ -1472,6 +1484,7 @@ p5.prototype.createSelect = function(...args) {
* // in the top-left corner.
* myRadio = createRadio();
* myRadio.position(0, 0);
+ * myRadio.class('p5-radio');
* myRadio.size(60);
*
* // Add a few color options.
@@ -1538,6 +1551,7 @@ p5.prototype.createSelect = function(...args) {
* // in the top-left corner.
* myRadio = createRadio();
* myRadio.position(0, 0);
+ * myRadio.class('p5-radio');
* myRadio.size(50);
*
* // Add a few color options.
diff --git a/src/webgl/p5.Framebuffer.js b/src/webgl/p5.Framebuffer.js
index 7a16d04a23..ac32c872ed 100644
--- a/src/webgl/p5.Framebuffer.js
+++ b/src/webgl/p5.Framebuffer.js
@@ -1752,7 +1752,7 @@ class Framebuffer {
*/
/**
- * An object that stores the framebuffer's dpeth data.
+ * An object that stores the framebuffer's depth data.
*
* Each framebuffer uses a
* WebGLTexture
diff --git a/src/webgl/p5.RendererGL.js b/src/webgl/p5.RendererGL.js
index f1e52b174e..908a056714 100644
--- a/src/webgl/p5.RendererGL.js
+++ b/src/webgl/p5.RendererGL.js
@@ -1667,6 +1667,8 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
// So that the activeImageLight gets reset in push/pop
properties.activeImageLight = this.activeImageLight;
+ properties.textureMode = this.textureMode;
+
return style;
}
pop(...args) {
diff --git a/test/unit/visual/cases/shape_modes.js b/test/unit/visual/cases/shape_modes.js
index d17565b320..8fa4c0f951 100644
--- a/test/unit/visual/cases/shape_modes.js
+++ b/test/unit/visual/cases/shape_modes.js
@@ -17,6 +17,12 @@ function shapeCorners(p5, shape, mode, x1, y1, x2, y2) {
// Don't use abs(), so we get negative values as well
let w = x2 - x1; // w
let h = y2 - y1; // h
+ // With mode CORNER, rects with negative widths/heights result in mirrored/flipped rendering
+ // In this case, adjust position so the rect is in line with the other cases
+ if (shape === 'rect') {
+ if (w < 0) { x += (-w); } // Move right
+ if (h < 0) { y += (-h); } // Move down
+ }
x1 = x; y1 = y; x2 = w; y2 = h;
} else if (mode === p5.CENTER) {
// Find center
@@ -56,14 +62,15 @@ function shapeCorners(p5, shape, mode, x1, y1, x2, y2) {
}
-/*
- Comprehensive test for rendering ellipse(), arc(), and rect()
- with the different ellipseMode() / rectMode() values: CORNERS, CORNER, CENTER, RADIUS.
- Each of the 3 shapes is tested with each of the 4 possible modes, resulting in 12 test.
- Each test renders the shape in 16 different coordinate configurations,
- testing combinations of positive and negative coordinate values.
-*/
visualSuite('Shape Modes', function(...args) {
+ /*
+ Comprehensive test for rendering ellipse(), arc(), and rect()
+ with the different ellipseMode() / rectMode() values: CORNERS, CORNER, CENTER, RADIUS.
+ Each of the 3 shapes is tested with each of the 4 possible modes, resulting in 12 tests.
+ Each test renders the shape in 16 different coordinate configurations,
+ testing combinations of positive and negative coordinate values.
+ */
+
// Shapes to test
const SHAPES = [ 'ellipse', 'arc', 'rect' ];
@@ -113,6 +120,60 @@ visualSuite('Shape Modes', function(...args) {
}); // End of: visualTest
} // End of: MODES loop
- }); // End of: Inner visualSuite
+ }); // End of: visualSuite
} // End of: SHAPES loop
-}); // End of: Outer visualSuite
+
+
+ /*
+ An extra test suite specific to shape mode CORNER and negative dimensions.
+ For rect, negative widths/heights result in flipped rendering (horizontally/vertically)
+ For ellipse and arc, using negative widths/heights has no effect (the absolute value is used)
+ */
+ visualSuite('Negative dimensions', function() {
+ // Negative widths/height result in flipped rects.
+ visualTest('rect', function(p5, screenshot) {
+ p5.createCanvas(50, 50);
+ p5.translate(p5.width/2, p5.height/2);
+ p5.rectMode(p5.CORNER);
+ p5.rect(0, 0, 20, 10);
+ p5.fill('red');
+ p5.rect(0, 0, -20, 10);
+ p5.fill('green');
+ p5.rect(0, 0, 20, -10);
+ p5.fill('blue');
+ p5.rect(0, 0, -20, -10);
+ screenshot();
+ });
+ // Since negative widths/heights are used with their absolute value,
+ // ellipses are drawn on top of each other, blue one last
+ visualTest('ellipse', function(p5, screenshot) {
+ p5.createCanvas(50, 50);
+ p5.translate(p5.width/2, p5.height/2);
+ p5.ellipseMode(p5.CORNER);
+ p5.ellipse(0, 0, 20, 10);
+ p5.fill('red');
+ p5.ellipse(0, 0, -20, 10);
+ p5.fill('green');
+ p5.ellipse(0, 0, 20, -10);
+ p5.fill('blue');
+ p5.ellipse(0, 0, -20, -10);
+ screenshot();
+ });
+ // Since negative widths/heights are used with their absolute value,
+ // arcs are drawn on top of each other, blue one last.
+ visualTest('arc', function(p5, screenshot) {
+ p5.createCanvas(50, 50);
+ p5.translate(p5.width/2, p5.height/2);
+ p5.ellipseMode(p5.CORNER);
+ p5.arc(0, 0, 20, 10, 0, p5.PI + p5.HALF_PI);
+ p5.fill('red');
+ p5.arc(0, 0, -20, 10, 0, p5.PI + p5.HALF_PI);
+ p5.fill('green');
+ p5.arc(0, 0, 20, -10, 0, p5.PI + p5.HALF_PI);
+ p5.fill('blue');
+ p5.arc(0, 0, -20, -10, 0, p5.PI + p5.HALF_PI);
+ screenshot();
+ });
+ });
+
+});
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/000.png b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/000.png
new file mode 100644
index 0000000000..b0732e0093
Binary files /dev/null and b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/000.png differ
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/metadata.json b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/metadata.json
new file mode 100644
index 0000000000..2d4bfe30da
--- /dev/null
+++ b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/arc/metadata.json
@@ -0,0 +1,3 @@
+{
+ "numScreenshots": 1
+}
\ No newline at end of file
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/000.png b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/000.png
new file mode 100644
index 0000000000..9351dc2adf
Binary files /dev/null and b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/000.png differ
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/metadata.json b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/metadata.json
new file mode 100644
index 0000000000..2d4bfe30da
--- /dev/null
+++ b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/ellipse/metadata.json
@@ -0,0 +1,3 @@
+{
+ "numScreenshots": 1
+}
\ No newline at end of file
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/000.png b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/000.png
new file mode 100644
index 0000000000..59aab0876f
Binary files /dev/null and b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/000.png differ
diff --git a/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/metadata.json b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/metadata.json
new file mode 100644
index 0000000000..2d4bfe30da
--- /dev/null
+++ b/test/unit/visual/screenshots/Shape Modes/Negative dimensions/rect/metadata.json
@@ -0,0 +1,3 @@
+{
+ "numScreenshots": 1
+}
\ No newline at end of file
diff --git a/test/unit/visual/screenshots/Shape Modes/Shape rect/Mode CORNER/000.png b/test/unit/visual/screenshots/Shape Modes/Shape rect/Mode CORNER/000.png
index 5c096e42bb..9e6ecdcd59 100644
Binary files a/test/unit/visual/screenshots/Shape Modes/Shape rect/Mode CORNER/000.png and b/test/unit/visual/screenshots/Shape Modes/Shape rect/Mode CORNER/000.png differ