MCPcopy
hub / github.com/processing/p5.js / assertGeometryRendersMatch

Function assertGeometryRendersMatch

test/unit/webgl/p5.Geometry.js:170–199  ·  view source on GitHub ↗
(drawGeometry, lightingModes)

Source from the content-addressed store, hash-verified

168 };
169 const checkNormals = () => myp5.normalMaterial();
170 function assertGeometryRendersMatch(drawGeometry, lightingModes) {
171 myp5.createCanvas(50, 50, myp5.WEBGL);
172 myp5.pixelDensity(1);
173 myp5.setAttributes({ antialias: false });
174
175 for (const applyLights of lightingModes) {
176 // Regular mode
177 myp5.background(255);
178 myp5.fill(255);
179 myp5.push();
180 applyLights();
181 drawGeometry();
182 myp5.pop();
183 myp5.resetShader();
184 const regularImage = myp5._renderer.canvas.toDataURL();
185
186 // Geometry mode
187 myp5.fill(255);
188 const geom = myp5.buildGeometry(drawGeometry);
189 myp5.background(255);
190 myp5.push();
191 applyLights();
192 myp5.model(geom);
193 myp5.pop();
194 myp5.resetShader();
195 const geometryImage = myp5._renderer.canvas.toDataURL();
196
197 assert.equal(regularImage, geometryImage);
198 }
199 }
200
201 test('Transforms are applied to models', function() {
202 assertGeometryRendersMatch(function() {

Callers 1

p5.Geometry.jsFile · 0.85

Calls 7

buildGeometryMethod · 0.80
modelMethod · 0.80
pixelDensityMethod · 0.45
backgroundMethod · 0.45
fillMethod · 0.45
pushMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected