diff --git a/sequencer/sequencer.js b/sequencer/sequencer.js index 5e8e9b2..35b451e 100644 --- a/sequencer/sequencer.js +++ b/sequencer/sequencer.js @@ -83,6 +83,14 @@ class S{ } } + set(option, value) { + this.config[option] = value; + } + + get(option) { + return this.config[option]; + } + load() { this.load = function() { console.log("load() can be called only once."); @@ -105,6 +113,7 @@ class S{ } else if (this.config.playMode === 'auto') { let pt = 0; const loop = (t)=> { + if (this.config.playMode !== 'auto') return; const dt = t - pt; if (dt >= this.config.interval) { this.nextImage(); @@ -116,6 +125,15 @@ class S{ } } + play() { + this.set('playMode', 'auto'); + this.run(); + } + + pause() { + this.set('playMode', 'none'); + } + nextImage(loop) { if (!loop) loop = this.config.loop; if(loop === 'pong') { @@ -167,7 +185,10 @@ class S{ const ox = (cw/2 - iw/2); const oy = (ch/2 - ih/2); - + + if (typeof drawImageCallback === 'function') + drawImageCallback(this, id); + this.ctx.save(); this.ctx.scale(r, r); this.ctx.clearRect(0, 0, cw, ch); // support for images with alpha