Skip to content

Commit

Permalink
- Added another sequence to examples
Browse files Browse the repository at this point in the history
- Set data-frame attribute to canvas with number of last drawn frame
  • Loading branch information
reindernijhoff committed Jul 3, 2024
1 parent fe17c0b commit 7976e06
Show file tree
Hide file tree
Showing 97 changed files with 16 additions and 11 deletions.
Binary file removed example/public/0001.webp
Binary file not shown.
Binary file removed example/public/0002.webp
Binary file not shown.
Binary file removed example/public/0003.webp
Binary file not shown.
Binary file removed example/public/0004.webp
Binary file not shown.
Binary file removed example/public/0005.webp
Binary file not shown.
Binary file removed example/public/0006.webp
Binary file not shown.
Binary file removed example/public/0007.webp
Binary file not shown.
Binary file removed example/public/0008.webp
Binary file not shown.
Binary file removed example/public/0009.webp
Binary file not shown.
Binary file removed example/public/0010.webp
Binary file not shown.
Binary file removed example/public/0011.webp
Binary file not shown.
Binary file removed example/public/0012.webp
Binary file not shown.
Binary file removed example/public/0013.webp
Binary file not shown.
Binary file removed example/public/0014.webp
Binary file not shown.
Binary file removed example/public/0015.webp
Binary file not shown.
Binary file removed example/public/0016.webp
Binary file not shown.
Binary file removed example/public/0017.webp
Binary file not shown.
Binary file removed example/public/0018.webp
Binary file not shown.
Binary file removed example/public/0019.webp
Binary file not shown.
Binary file removed example/public/0020.webp
Binary file not shown.
Binary file removed example/public/0021.webp
Binary file not shown.
Binary file removed example/public/0022.webp
Binary file not shown.
Binary file removed example/public/0023.webp
Binary file not shown.
Binary file removed example/public/0024.webp
Binary file not shown.
Binary file removed example/public/0025.webp
Binary file not shown.
Binary file removed example/public/0026.webp
Binary file not shown.
Binary file removed example/public/0027.webp
Binary file not shown.
Binary file removed example/public/0028.webp
Binary file not shown.
Binary file removed example/public/0029.webp
Binary file not shown.
Binary file removed example/public/0030.webp
Binary file not shown.
Binary file removed example/public/0031.webp
Binary file not shown.
Binary file removed example/public/0032.webp
Binary file not shown.
Binary file removed example/public/0033.webp
Binary file not shown.
Binary file removed example/public/0034.webp
Binary file not shown.
Binary file removed example/public/0035.webp
Binary file not shown.
Binary file removed example/public/0036.webp
Binary file not shown.
Binary file removed example/public/0037.webp
Binary file not shown.
Binary file removed example/public/0038.webp
Binary file not shown.
Binary file removed example/public/0039.webp
Binary file not shown.
Binary file removed example/public/0040.webp
Binary file not shown.
Binary file removed example/public/0041.webp
Binary file not shown.
Binary file removed example/public/0042.webp
Binary file not shown.
Binary file removed example/public/0043.webp
Binary file not shown.
Binary file removed example/public/0044.webp
Binary file not shown.
Binary file removed example/public/0045.webp
Binary file not shown.
Binary file removed example/public/0046.webp
Binary file not shown.
Binary file removed example/public/0047.webp
Binary file not shown.
Binary file removed example/public/0048.webp
Binary file not shown.
Binary file removed example/public/0049.webp
Binary file not shown.
Binary file removed example/public/0050.webp
Binary file not shown.
Binary file removed example/public/0051.webp
Binary file not shown.
Binary file removed example/public/0052.webp
Binary file not shown.
Binary file removed example/public/0053.webp
Binary file not shown.
Binary file removed example/public/0054.webp
Binary file not shown.
Binary file removed example/public/0055.webp
Binary file not shown.
Binary file removed example/public/0056.webp
Binary file not shown.
Binary file removed example/public/0057.webp
Binary file not shown.
Binary file removed example/public/0058.webp
Binary file not shown.
Binary file removed example/public/0059.webp
Binary file not shown.
Binary file removed example/public/0060.webp
Binary file not shown.
Binary file removed example/public/0061.webp
Binary file not shown.
Binary file removed example/public/0062.webp
Binary file not shown.
Binary file removed example/public/0063.webp
Binary file not shown.
Binary file removed example/public/0064.webp
Binary file not shown.
Binary file removed example/public/0065.webp
Binary file not shown.
Binary file removed example/public/0066.webp
Binary file not shown.
Binary file removed example/public/0067.webp
Binary file not shown.
Binary file removed example/public/0068.webp
Binary file not shown.
Binary file removed example/public/0069.webp
Binary file not shown.
Binary file removed example/public/0070.webp
Binary file not shown.
Binary file removed example/public/0071.webp
Binary file not shown.
Binary file removed example/public/0072.webp
Binary file not shown.
Binary file removed example/public/0073.webp
Binary file not shown.
Binary file removed example/public/0074.webp
Binary file not shown.
Binary file removed example/public/0075.webp
Binary file not shown.
Binary file removed example/public/0076.webp
Binary file not shown.
Binary file removed example/public/0077.webp
Binary file not shown.
Binary file removed example/public/0078.webp
Binary file not shown.
Binary file removed example/public/0079.webp
Binary file not shown.
Binary file removed example/public/0080.webp
Binary file not shown.
Binary file removed example/public/0081.webp
Binary file not shown.
Binary file removed example/public/0082.webp
Binary file not shown.
Binary file removed example/public/0083.webp
Binary file not shown.
Binary file removed example/public/0084.webp
Binary file not shown.
Binary file removed example/public/0085.webp
Binary file not shown.
Binary file removed example/public/0086.webp
Binary file not shown.
Binary file removed example/public/0087.webp
Binary file not shown.
Binary file removed example/public/0088.webp
Binary file not shown.
Binary file removed example/public/0089.webp
Binary file not shown.
Binary file removed example/public/0090.webp
Binary file not shown.
Binary file removed example/public/lowrespreviews.tar
Binary file not shown.
4 changes: 2 additions & 2 deletions example/src/exampleConstructDestructTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ function createFastImageSequence(container) {
const src = [];

const imageSrc = {
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`,
imageURL: (i) => `sequence_1/${('' + (i + 1)).padStart(4, '0')}.webp`,
useWorker: Math.random() > .5, // default true
maxCachedImages: (1 + Math.random() * 32) | 0, // default 32
};
const tarSrc = {
tarURL: 'lowrespreviews.tar',
tarURL: 'sequence_1/lowrespreviews.tar',
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.jpg`,
useWorker: Math.random() > .5, // default true
maxCachedImages: (1 + Math.random() * 32) | 0, // default 32
Expand Down
2 changes: 1 addition & 1 deletion example/src/exampleLoadTar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function blobToDataURL(blob) {

export async function initExampleLoadTar(container) {
// load tar file with lowres previews
fetch('lowrespreviews.tar').then(async (response) => {
fetch('sequence_1/lowrespreviews.tar').then(async (response) => {
const blob = await response.blob();
const dataURL = await blobToDataURL(blob);

Expand Down
6 changes: 3 additions & 3 deletions example/src/examplePlayBackwards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {FastImageSequence} from '../../src/index';
export async function initExamplePlayBackwards(container) {
const fastImageSequence = new FastImageSequence(container, {
name: 'PlayBackwardsTest at 200fps',
frames: 89,
frames: 120,
src: {
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`,
imageURL: (i) => `sequence_2/${('' + (i + 1)).padStart(3, '0')}.jpg`,
},
// optional arguments:
loop: true, // default false
objectFit: 'cover', // default 'cover'
objectFit: 'contain', // default 'cover'
fillStyle: '#00000000', // default #00000000
clearCanvas: false, // default false
showDebugInfo: true,
Expand Down
2 changes: 1 addition & 1 deletion example/src/exampleStillImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function initExampleStillImage(container) {
name: 'StillImageTest',
frames: 89,
src: {
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`,
imageURL: (i) => `sequence_1/${('' + (i + 1)).padStart(4, '0')}.webp`,
maxCachedImages: 1, // default 32
useWorker: true,
},
Expand Down
4 changes: 2 additions & 2 deletions example/src/exampleWithControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export async function initExampleWithControl(container) {
frames: 89,
src: [
{
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`,
imageURL: (i) => `sequence_1/${('' + (i + 1)).padStart(4, '0')}.webp`,
maxCachedImages: 8, // default 32
},
{
tarURL: 'lowrespreviews.tar',
tarURL: 'sequence_1/lowrespreviews.tar',
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.jpg`
}
],
Expand Down
9 changes: 7 additions & 2 deletions src/lib/FastImageSequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,12 @@ export class FastImageSequence {
this.log('Poster image', this.options.poster);
const posterImage = new Image();
posterImage.src = this.options.poster;
await posterImage.decode().then(() => this.drawImage(this.posterImage = posterImage)).catch((e) => this.log(e));
await posterImage.decode().then(() => {
this.posterImage = posterImage;
if (this.lastFrameDrawn < 0) {
this.drawImage(this.posterImage);
}
}).catch((e) => this.log(e));
}
await Promise.all(this.sources.map(src => src.loadResources()));
await this.getFrameImage(0);
Expand Down Expand Up @@ -436,7 +441,7 @@ export class FastImageSequence {
}

this.lastFrameDrawn = frame.index;

this.canvas.setAttribute('data-frame', frame.index.toString());
this.drawImage(image);
}

Expand Down

0 comments on commit 7976e06

Please sign in to comment.