* Sets the current frame in an animated GIF. * * @param {Number} index index of the frame to display. * * @example * let gif; * let frameSlider; * * async function setup() { * // Load the image. * gif = await loadImage('assets/arnott-wallace-eye-loop-forever.gif');
(index)
| 1597 | * } |
| 1598 | */ |
| 1599 | setFrame(index) { |
| 1600 | if (this.gifProperties) { |
| 1601 | const props = this.gifProperties; |
| 1602 | if (index < props.numFrames && index >= 0) { |
| 1603 | props.timeDisplayed = 0; |
| 1604 | props.lastChangeTime = 0; |
| 1605 | props.displayIndex = index; |
| 1606 | this.drawingContext.putImageData(props.frames[index].image, 0, 0); |
| 1607 | } else { |
| 1608 | this._friendlyError( |
| 1609 | 'Cannot set GIF to a frame number that is higher than total number of frames or below zero.', |
| 1610 | 'setFrame' |
| 1611 | ); |
| 1612 | } |
| 1613 | } |
| 1614 | } |
| 1615 | |
| 1616 | /** |
| 1617 | * Returns the number of frames in an animated GIF. |
no test coverage detected