Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/webgl/ShaderGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1615,8 +1615,10 @@ function shadergenerator(p5, fn) {
'asin': { args: ['genType'], returnType: 'genType', isp5Function: true },
'asinh': { args: ['genType'], returnType: 'genType', isp5Function: false },
'atan': [
{ args: ['genType'], returnType: 'genType', isp5Function: false },
{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: false }
// Single-argument atan is a normal p5 function and should work outside strands
{ args: ['genType'], returnType: 'genType', isp5Function: true},
// Two-argument atan(y, x) is GLSL-only and remains strands-only
{ args: ['genType', 'genType'], returnType: 'genType', isp5Function: false},
],
'atanh': { args: ['genType'], returnType: 'genType', isp5Function: false },
'cos': { args: ['genType'], returnType: 'genType', isp5Function: true },
Expand Down
3 changes: 2 additions & 1 deletion test/unit/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ var spec = {
// to omit some for speed if they should only be run manually.
'webgl',
'typography',
'shape_modes'
'shape_modes',
'math'
]
};
document.write(
Expand Down
17 changes: 17 additions & 0 deletions test/unit/visual/cases/math.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { visualTest, visualSuite } from '../../visual/visualTest.js';

visualSuite('math', () => {
visualTest('atan_outside_strands', async (p5, screenshot) => {
// Ensure no WebGL/strands context is used; call atan directly and draw text
p5.createCanvas(120, 60);
p5.background(255);
p5.fill(0);
const v = p5.atan(0.5);
// Draw the numeric value so visual regression will catch undefined/NaN
p5.textSize(14);
p5.textFont('monospace');
p5.textAlign(p5.LEFT, p5.TOP);
p5.text(`atan(0.5)=${p5.nf(v, 1, 3)}`, 5, 5);
screenshot();
});
});
Loading