-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- p5.strands
- WebGL
- DevOps, Build process, Unit testing
- Internationalization (i18n)
- Friendly Errors
- Other (specify if possible)
p5.js version
p5.js VERSION: 2.x (main)
Web browser and version
Any
Operating system
No response
Steps to reproduce this
STEPS TO REPRODUCE THIS:
When calling setFrame() on a p5.Image (GIF) with an out-of-range frame index, the error message is displayed via raw console.log() instead of the Friendly Error System. This means the warning is not suppressed by p5.disableFriendlyErrors = true and cannot be translated via i18n.
Steps:
- Load an animated GIF
- Call
setFrame()with an index greater than the total number of frames or below zero - Observe the browser console — a raw
console.logmessage appears even if FES is disabled
Snippet:
let gif;
function preload() {
gif = loadImage('assets/my-animation.gif');
}
function setup() {
createCanvas(100, 100);
p5.disableFriendlyErrors = true;
gif.setFrame(99999); // logs warning via console.log, not FES
}Current code at src/image/p5.Image.js line 1802-1816:
setFrame(index) {
if (this.gifProperties) {
const props = this.gifProperties;
if (index < props.numFrames && index >= 0) {
props.timeDisplayed = 0;
props.lastChangeTime = 0;
props.displayIndex = index;
this.drawingContext.putImageData(props.frames[index].image, 0, 0);
} else {
console.log(
'Cannot set GIF to a frame number that is higher than total number of frames or below zero.'
);
}
}
}Expected behavior: The validation error should use p5._friendlyError() so it respects p5.disableFriendlyErrors and can be translated via the i18n system.
Additional context:
This is a one-file, small fix consistent with ongoing FES migration efforts across the codebase. The error message is also hardcoded in English, making it inaccessible for non-English speaking users.
I'd be happy to work on this if it gets approved!