From 1cb1fde94bf754db06f91548a3fe650dfe64a52b Mon Sep 17 00:00:00 2001 From: Dave Pagurek Date: Sat, 14 Dec 2024 11:45:22 -0500 Subject: [PATCH] Fix more tests referring to TESS --- src/shape/vertex.js | 17 +++++++-------- src/webgl/ShapeBuilder.js | 4 ++-- .../webgl/geometryImmediate/sketch.js | 2 +- test/unit/core/structure.js | 13 +----------- test/unit/visual/cases/shapes.js | 12 +---------- test/unit/visual/cases/webgl.js | 4 ++-- .../000.png | Bin 874 -> 771 bytes .../vertexProperty/on PATH shape mode/000.png | Bin 0 -> 878 bytes .../metadata.json | 0 .../vertexProperty/on TESS shape mode/000.png | Bin 879 -> 0 bytes test/unit/webgl/p5.RendererGL.js | 20 +++++++++--------- 11 files changed, 25 insertions(+), 47 deletions(-) create mode 100644 test/unit/visual/screenshots/WebGL/vertexProperty/on PATH shape mode/000.png rename test/unit/visual/screenshots/WebGL/vertexProperty/{on TESS shape mode => on PATH shape mode}/metadata.json (100%) delete mode 100644 test/unit/visual/screenshots/WebGL/vertexProperty/on TESS shape mode/000.png diff --git a/src/shape/vertex.js b/src/shape/vertex.js index 2d98f12cf2..34f452f45f 100644 --- a/src/shape/vertex.js +++ b/src/shape/vertex.js @@ -17,9 +17,9 @@ function vertex(p5, fn){ * vertices to a custom shape and endShape() stops * adding them. * - * The parameter, `kind`, sets the kind of shape to make. By default, any - * irregular polygon can be drawn. The available modes for kind are: + * The parameter, `kind`, sets the kind of shape to make. The available kinds are: * + * - `PATH` (the default) to draw shapes by tracing out the path along their edges. * - `POINTS` to draw a series of points. * - `LINES` to draw a series of unconnected line segments. * - `TRIANGLES` to draw a series of separate triangles. @@ -27,13 +27,12 @@ function vertex(p5, fn){ * - `TRIANGLE_STRIP` to draw a series of connected triangles in strip fashion. * - `QUADS` to draw a series of separate quadrilaterals (quads). * - `QUAD_STRIP` to draw quad strip using adjacent edges to form the next quad. - * - `TESS` to create a filling curve by explicit tessellation (WebGL only). * * After calling `beginShape()`, shapes can be built by calling * vertex(), * bezierVertex(), - * quadraticVertex(), and/or - * splineVertex(). Calling + * bezierVertex(), and/or + * splineVertex(). Calling * endShape() will stop adding vertices to the * shape. Each shape will be outlined with the current stroke color and filled * with the current fill color. @@ -47,8 +46,8 @@ function vertex(p5, fn){ * endShape(). * * @method beginShape - * @param {(POINTS|LINES|TRIANGLES|TRIANGLE_FAN|TRIANGLE_STRIP|QUADS|QUAD_STRIP|TESS)} [kind] either POINTS, LINES, TRIANGLES, TRIANGLE_FAN - * TRIANGLE_STRIP, QUADS, QUAD_STRIP or TESS. + * @param {(POINTS|LINES|TRIANGLES|TRIANGLE_FAN|TRIANGLE_STRIP|QUADS|QUAD_STRIP|PATH)} [kind=PATH] either POINTS, LINES, TRIANGLES, TRIANGLE_FAN + * TRIANGLE_STRIP, QUADS, QUAD_STRIP or PATH. Defaults to PATH. * @chainable * * @example @@ -334,7 +333,7 @@ function vertex(p5, fn){ * * // Start drawing the shape. * // Draw a series of quadrilaterals. - * beginShape(TESS); + * beginShape(PATH); * * // Add the vertices. * vertex(-30, -30, 0); @@ -373,7 +372,7 @@ function vertex(p5, fn){ * * // Start drawing the shape. * // Draw a series of quadrilaterals. - * beginShape(TESS); + * beginShape(PATH); * * // Add the vertices. * fill('red'); diff --git a/src/webgl/ShapeBuilder.js b/src/webgl/ShapeBuilder.js index c36658752d..946e28ad34 100644 --- a/src/webgl/ShapeBuilder.js +++ b/src/webgl/ShapeBuilder.js @@ -20,7 +20,7 @@ const INITIAL_VERTEX_SIZE = export class ShapeBuilder { constructor(renderer) { this.renderer = renderer; - this.shapeMode = constants.TESS; + this.shapeMode = constants.PATH; this.geometry = new Geometry(undefined, undefined, undefined, this.renderer); this.geometry.gid = '__IMMEDIATE_MODE_GEOMETRY__'; @@ -253,7 +253,7 @@ export class ShapeBuilder { * @private */ _tesselateShape() { - // TODO: handle non-TESS shape modes that have contours + // TODO: handle non-PATH shape modes that have contours this.shapeMode = constants.TRIANGLES; // const contours = [[]]; const contours = []; diff --git a/test/manual-test-examples/webgl/geometryImmediate/sketch.js b/test/manual-test-examples/webgl/geometryImmediate/sketch.js index 27ce74a562..8ec44bc3fd 100644 --- a/test/manual-test-examples/webgl/geometryImmediate/sketch.js +++ b/test/manual-test-examples/webgl/geometryImmediate/sketch.js @@ -82,7 +82,7 @@ function drawStrip(mode) { } function ngon(n, x, y, d) { - beginShape(TESS); + beginShape(PATH); for (let i = 0; i < n + 1; i++) { angle = TWO_PI / n * i; px = x + sin(angle) * d / 2; diff --git a/test/unit/core/structure.js b/test/unit/core/structure.js index cf972f5395..1dd708db78 100644 --- a/test/unit/core/structure.js +++ b/test/unit/core/structure.js @@ -58,18 +58,7 @@ suite('Structure', function() { suite('p5.prototype.push and p5.prototype.pop', function() { function getRenderState() { - var state = {}; - for (var key in myp5._renderer) { - var value = myp5._renderer[key]; - if ( - typeof value !== 'function' && - key !== '_cachedFillStyle' && - key !== '_cachedStrokeStyle' - ) { - state[key] = value; - } - } - return state; + return { ...myp5._renderer.states }; } function assertCanPreserveRenderState(work) { diff --git a/test/unit/visual/cases/shapes.js b/test/unit/visual/cases/shapes.js index 15bd1e1fdf..ecc710e2bf 100644 --- a/test/unit/visual/cases/shapes.js +++ b/test/unit/visual/cases/shapes.js @@ -146,16 +146,6 @@ visualSuite('Shape drawing', function() { p5.splineVertex(15, 40); p5.splineVertex(40, 35); p5.endShape(); - - p5.strokeWeight(10); - p5.stroke('red') - p5.beginShape(p5.POINTS) - p5.vertex(10, 10); - p5.vertex(15, 40); - p5.vertex(40, 35); - p5.vertex(25, 15); - p5.vertex(15, 25); - p5.endShape(); screenshot(); }); @@ -211,8 +201,8 @@ visualSuite('Shape drawing', function() { p5.vertex(15, 40); p5.vertex(40, 35); p5.vertex(25, 15); - p5.vertex(15, 25); p5.vertex(10, 10); + p5.vertex(15, 25); p5.endShape(); screenshot(); }); diff --git a/test/unit/visual/cases/webgl.js b/test/unit/visual/cases/webgl.js index 8b77b6cc46..91bc52ddd2 100644 --- a/test/unit/visual/cases/webgl.js +++ b/test/unit/visual/cases/webgl.js @@ -151,12 +151,12 @@ visualSuite('WebGL', function() { outColor = vec4(vCol, 1.0); }`; visualTest( - 'on TESS shape mode', function(p5, screenshot) { + 'on PATH shape mode', function(p5, screenshot) { p5.createCanvas(50, 50, p5.WEBGL); p5.background('white'); const myShader = p5.createShader(vertSrc, fragSrc); p5.shader(myShader); - p5.beginShape(p5.TESS); + p5.beginShape(p5.PATH); p5.noStroke(); for (let i = 0; i < 20; i++){ let x = 20 * p5.sin(i/20*p5.TWO_PI); diff --git a/test/unit/visual/screenshots/Shape drawing/WebGL mode/Drawing with curves with tightness/000.png b/test/unit/visual/screenshots/Shape drawing/WebGL mode/Drawing with curves with tightness/000.png index 70d1c096b2a872a9f02d90b0a31cf4c98831651a..8d123f745f2f7dcb2bcf88aa0728cc44199c5a56 100644 GIT binary patch delta 735 zcmV<50wDeB27?BWFnBND&i`lXa`)^Qnazs(+Vll?RMD$sZ>gOA%E2ag+aVtFC>#m)%Hlw zF9fpLY@pxoL#x%2UP$#oVUWRK0F6dNwLQ}FlR$>UAsh||;l+4tg+d{~M`aTNK?B0! zFr3e4*lxF$_8vgu{ zukI!4Qf7p9!bpL>UNU1s=mj5G+k7k{Qxvs6p92w_H}(MRWuFbJkr zzu*6i16;UPt663#Q7DALszElBNrQ+QNa+`iMj;RgNWpv+2tsR`1~TzN0`d8LP_0%e zn@sMDE_OPd$af!MkWbPqm8MWAFc?a_2!rqn7z;-y8r8+V7KEC`NFcdfj>U*bJ!OY# z6jewd#(%TK4rAZVK~d%Z1mRy(7K?>yG1&ad6mc?hQ7dDTYaxgeal$KN$}N%%g6@@0 zr$N@dzROF2@L0k7h%5~5JT{yolgYsKdL@-4 z#*L8%K^N=wdf@SRpi-%@dCd+=3|efn*^C*B?^w&_@@X`so_eRMGzg!R1L6C6z5Z*h zNF)OH`yGP8Ap1?#=hKft963+~7I8rYHp$U0t|E?Zx4>eqA_AM_XqR83$PevJBu};W Ra0&nb002ovPDHL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xn2)L;;`}H;<{86@m`3lO_@uuTTsFL`L>9vk<(RTcg}5v)7m!no;Y>mrnGjd0 zxPV*;Lrf>6kqL2?iY;V;F`Q3HLkr>}6BRH^AM^-Um6BCHuA zazmn0(*@~3wusQo0f>H!cC)A5`(}aCAUBE7vH&=R^d_XX+wJzhvQx<#1CKY6;kdL$r41poj507*qoM6N<$ Eg8CPeJOBUy literal 0 HcmV?d00001 diff --git a/test/unit/visual/screenshots/WebGL/vertexProperty/on TESS shape mode/metadata.json b/test/unit/visual/screenshots/WebGL/vertexProperty/on PATH shape mode/metadata.json similarity index 100% rename from test/unit/visual/screenshots/WebGL/vertexProperty/on TESS shape mode/metadata.json rename to test/unit/visual/screenshots/WebGL/vertexProperty/on PATH shape mode/metadata.json diff --git a/test/unit/visual/screenshots/WebGL/vertexProperty/on TESS shape mode/000.png b/test/unit/visual/screenshots/WebGL/vertexProperty/on TESS shape mode/000.png deleted file mode 100644 index 76ef1d98a21dcb9ff7caf29e4cf5f5182e0b3c9d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 879 zcmV-#1CacQP)Px&DM>^@RA@u(*}rQOVHgMS?WZPYbAzNZyiSfESH$G z^Wg*{ehAP{O8ij@a(w80?C`EOby|d_mOe%sBHjwnJ99){h)SouNN6qTVYDD(SAcf&A#5NDv)Cpy+u4{*i2N$S zpK_ymJ-D-Jj~wiog$|+7NylVD_+t+FN&Z)ef?c|ozDQ4n$d3~IkzE?LrKQSCL7H7c zy_=j$DumzXkRR;Qa0OAIa}SbJNrcGv5`5b}4VRG98-$r&d@6|$?sLdD_G!3;s8miq ziBBaKB411JyKd5O4tZ_@c_qPb6%#V|FhFT#bS)N}h}aRJo%{pP^&AkITtH4ShBFCiWI|k} z;sSC$2vAK(BNO5(6RH^AM^-UmMB6JK9 zxgk-h>4J11JtA~-0HWWb-Rx=izFD9&$W0>jEC5a+!wISFe!u^(>=bhF_cUYRjA0tU z>iRlXGUkHmLjxy?n11Ov_Mbq;aaL_UbCQV7*&D~Pe*k$hx_TM4%D4ak002ovPDHLk FV1oJ0iW~p{ diff --git a/test/unit/webgl/p5.RendererGL.js b/test/unit/webgl/p5.RendererGL.js index 122cd366cc..c9b02f7da7 100644 --- a/test/unit/webgl/p5.RendererGL.js +++ b/test/unit/webgl/p5.RendererGL.js @@ -1641,11 +1641,11 @@ suite('p5.RendererGL', function() { assert.equal(renderer.shapeBuilder.geometry.edges.length, 7); }); - test('TESS preserves vertex data', function() { + test('PATH preserves vertex data', function() { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); myp5.textureMode(myp5.NORMAL); - myp5.beginShape(myp5.TESS); + myp5.beginShape(myp5.PATH); myp5.fill(255, 255, 255); myp5.normal(-1, -1, 1); myp5.vertexProperty('aCustom', [1, 1, 1]) @@ -1744,11 +1744,11 @@ suite('p5.RendererGL', function() { ]); }); - test('TESS does not affect stroke colors', function() { + test('PATH does not affect stroke colors', function() { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); myp5.textureMode(myp5.NORMAL); - myp5.beginShape(myp5.TESS); + myp5.beginShape(myp5.PATH); myp5.noFill(); myp5.stroke(255, 255, 255); myp5.vertex(-10, -10, 0, 0); @@ -1769,13 +1769,13 @@ suite('p5.RendererGL', function() { ]); }); - test('TESS does not affect texture coordinates', function() { + test('PATH does not affect texture coordinates', function() { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); const texture = new p5.Image(25, 25); myp5.textureMode(myp5.IMAGE); myp5.texture(texture); - myp5.beginShape(myp5.TESS); + myp5.beginShape(myp5.PATH); myp5.noFill(); myp5.vertex(-10, -10, 0, 0); myp5.vertex(10, -10, 25, 0); @@ -1792,7 +1792,7 @@ suite('p5.RendererGL', function() { ]); }); - test('TESS interpolates vertex data at intersections', function() { + test('PATH interpolates vertex data at intersections', function() { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); // Hourglass shape: @@ -1806,7 +1806,7 @@ suite('p5.RendererGL', function() { // // Tessy will add a vertex in the middle myp5.textureMode(myp5.NORMAL); - myp5.beginShape(myp5.TESS); + myp5.beginShape(myp5.PATH); myp5.fill(255, 255, 255); myp5.normal(-1, -1, 1); myp5.vertex(-10, -10, 0, 0); @@ -1892,11 +1892,11 @@ suite('p5.RendererGL', function() { ]); }); - test('TESS handles vertex data perpendicular to the camera', function() { + test('PATH handles vertex data perpendicular to the camera', function() { var renderer = myp5.createCanvas(10, 10, myp5.WEBGL); myp5.textureMode(myp5.NORMAL); - myp5.beginShape(myp5.TESS); + myp5.beginShape(myp5.PATH); myp5.vertex(-10, 0, -10); myp5.vertex(10, 0, -10); myp5.vertex(10, 0, 10);