-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix typing, improve examples/testing, fix destruct methods
- Loading branch information
1 parent
0fa1fc2
commit ab3dcf3
Showing
10 changed files
with
213 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import {FastImageSequence} from '../../src/index'; | ||
|
||
export function constructDestructTest(container) { | ||
let fastImageSequence = createFastImageSequence(container); | ||
|
||
// construct a FastImageSequence every 3 seconds, and destruct it after 5 seconds | ||
setInterval(() => { | ||
console.log('destructing'); | ||
fastImageSequence.destruct(); | ||
console.log('constructing'); | ||
fastImageSequence = createFastImageSequence(container); | ||
}, 3000); | ||
} | ||
|
||
function createFastImageSequence(container) { | ||
const fastImageSequence = new FastImageSequence(container, { | ||
frames: 89, | ||
imageURLCallback: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`, | ||
tarURL: '/lowrespreviews.tar', | ||
tarImageURLCallback: (i) => `${('' + (i + 1)).padStart(4, '0')}.jpg`, | ||
|
||
// optional arguments: | ||
wrap: Math.random() > .5, // default false | ||
size: Math.random() > .5 ? 'cover' : 'contain', // default 'cover' | ||
fillStyle: '#00000000', // default #00000000 | ||
preloadAllTarImages: Math.random() > .5, | ||
useWorkerForTar: Math.random() > .5, // default true | ||
numberOfCachedImages: 32, // default 32 | ||
clearCanvas: Math.random() > .5, // default false | ||
}); | ||
|
||
fastImageSequence.ready.then(() => { | ||
fastImageSequence.play(30); | ||
}); | ||
|
||
return fastImageSequence; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { FastImageSequence } from '../../src/index'; | ||
|
||
export async function initExamplePlayBackwards(container) { | ||
const fastImageSequence = new FastImageSequence(container, { | ||
frames: 89, | ||
imageURLCallback: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`, | ||
// tarURL: '/lowrespreviews.tar', | ||
// tarImageURLCallback: (i) => `${('' + (i+1)).padStart(4, '0')}.jpg`, | ||
|
||
// optional arguments: | ||
wrap: true, // default false | ||
size: 'cover', // default 'cover' | ||
fillStyle: '#00000000', // default #00000000 | ||
preloadAllTarImages: false, | ||
useWorkerForTar: true, // default true | ||
numberOfCachedImages: 32, // default 32 | ||
clearCanvas: false, // default false | ||
}); | ||
|
||
await fastImageSequence.ready; | ||
|
||
fastImageSequence.progress = 0; | ||
|
||
fastImageSequence.play(-30); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { FastImageSequence } from '../../src/index'; | ||
|
||
export async function initExampleStillImage(container) { | ||
const fastImageSequence = new FastImageSequence(container, { | ||
frames: 89, | ||
imageURLCallback: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`, | ||
// tarURL: '/lowrespreviews.tar', | ||
// tarImageURLCallback: (i) => `${('' + (i+1)).padStart(4, '0')}.jpg`, | ||
|
||
// optional arguments: | ||
wrap: true, // default false | ||
size: 'cover', // default 'cover' | ||
fillStyle: '#00000000', // default #00000000 | ||
preloadAllTarImages: false, | ||
useWorkerForTar: true, // default true | ||
numberOfCachedImages: 32, // default 32 | ||
clearCanvas: false, // default false | ||
}); | ||
|
||
await fastImageSequence.ready; | ||
|
||
console.log('fastImageSequence loaded'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { FastImageSequence } from '../../src/index'; | ||
|
||
const prevButton = document.getElementById('prev-button'); | ||
const nextButton = document.getElementById('next-button'); | ||
const progress = document.getElementById('slider-input'); | ||
|
||
export async function initExampleWithControl(container) { | ||
const fastImageSequence = new FastImageSequence(container, { | ||
frames: 89, | ||
imageURLCallback: (i) => `${('' + (i+1)).padStart(4, '0')}.webp`, | ||
tarURL: '/lowrespreviews.tar', | ||
tarImageURLCallback: (i) => `${('' + (i+1)).padStart(4, '0')}.jpg`, | ||
|
||
// optional arguments: | ||
wrap: true, // default false | ||
size: 'contain', // default 'cover' | ||
fillStyle: '#00000000', // default #00000000 | ||
preloadAllTarImages: false, | ||
useWorkerForTar: true, // default true | ||
numberOfCachedImages: 32, // default 32 | ||
clearCanvas: false, // default false | ||
}); | ||
|
||
await fastImageSequence.ready; | ||
|
||
fastImageSequence.progress = 0; | ||
|
||
fastImageSequence.tick((dt) => { | ||
if (fastImageSequence.isPlaying) { | ||
progress.value = fastImageSequence.progress; | ||
} | ||
}); | ||
|
||
prevButton.addEventListener('click', () => { | ||
fastImageSequence.play(-30); | ||
}); | ||
nextButton.addEventListener('click', () => { | ||
fastImageSequence.play(30); | ||
}); | ||
progress.addEventListener('mousedown', (e) => { | ||
fastImageSequence.stop(); | ||
}); | ||
progress.addEventListener('input', () => { | ||
if (fastImageSequence.isPaused) { | ||
fastImageSequence.progress = progress.value; | ||
} | ||
}); | ||
|
||
fastImageSequence.play(30); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,9 @@ | ||
// import {FastImageSequence} from '@mediamonks/fast-image-sequence'; | ||
import {FastImageSequence} from '../../src/index'; | ||
|
||
const container = document.getElementsByClassName('container')[0]; | ||
const prevButton = document.getElementById('prev-button'); | ||
const nextButton = document.getElementById('next-button'); | ||
const progress = document.getElementById('slider-input'); | ||
|
||
async function init() { | ||
const fastImageSequence = new FastImageSequence(container, { | ||
frames: 89, | ||
imageURLCallback: (i) => `./public/${('' + (i+1)).padStart(4, '0')}.webp`, | ||
tarURL: '/lowrespreviews.tar', | ||
tarImageURLCallback: (i) => `${('' + (i+1)).padStart(4, '0')}.jpg`, | ||
|
||
// optional arguments: | ||
wrap: true, // default false | ||
size: 'contain', // default 'cover' | ||
fillStyle: '#00000000', // default #00000000 | ||
preloadAllTarImages: false, | ||
useWorkerForTar: true, // default true | ||
numberOfCachedImages: 32, // default 32 | ||
clearCanvas: false, // default false | ||
}); | ||
|
||
await fastImageSequence.ready; | ||
|
||
document.getElementsByClassName('loading')[0].remove(); | ||
fastImageSequence.progress = 0; | ||
|
||
fastImageSequence.tick((dt) => { | ||
if (fastImageSequence.isPlaying) { | ||
progress.value = fastImageSequence.progress; | ||
} | ||
}); | ||
|
||
prevButton.addEventListener('click', () => { | ||
fastImageSequence.play(-30); | ||
}); | ||
nextButton.addEventListener('click', () => { | ||
fastImageSequence.play(30); | ||
}); | ||
progress.addEventListener('mousedown', (e) => { | ||
fastImageSequence.stop(); | ||
}); | ||
progress.addEventListener('input', () => { | ||
if (fastImageSequence.isPaused) { | ||
fastImageSequence.progress = progress.value; | ||
} | ||
}); | ||
|
||
fastImageSequence.play(30); | ||
|
||
console.log(fastImageSequence); | ||
} | ||
|
||
|
||
init(); | ||
import {initExampleWithControl} from "./exampleWithControl.js"; | ||
import {initExamplePlayBackwards} from "./examplePlayBackwards.js"; | ||
import {initExampleStillImage} from "./exampleStillImage.js"; | ||
import {constructDestructTest} from "./exampleConstructDestructTest.js"; | ||
|
||
initExampleWithControl(document.getElementsByClassName('grid-item')[0]); | ||
initExamplePlayBackwards(document.getElementsByClassName('grid-item')[1]); | ||
initExampleStillImage(document.getElementsByClassName('grid-item')[2]); | ||
constructDestructTest(document.getElementsByClassName('grid-item')[3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export {default as FastImageSequence} from './lib/FastImageSequence.js'; | ||
export * from './lib/FastImageSequence.js'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.