This file contains hidden or 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
loader = { | |
// arreglo con ruta de las imágenes | |
images: [], | |
// Se ejecuta al cargar las imágenes | |
onComplete: function(){}, | |
init: function(){ | |
var self = this, count = 0; | |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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
/** | |
* A super-basic Javascript (publish subscribe) pattern | |
* https://www.youtube.com/watch?v=nQRXi1SVOow | |
* https://gist.github.com/learncodeacademy/777349747d8382bfb722 | |
* | |
* @export | |
* @class Events | |
*/ | |
export default class Events { |
This file contains hidden or 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
// Events class is here: https://gist.github.com/schmidtsonian/8a023034a2f5600b455afd2e2aed7019 | |
import Events from './events'; | |
/** | |
* Watcher | |
* | |
* @class Watcher | |
*/ | |
export default class Watcher { |
This file contains hidden or 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
/** | |
* Creates and loads a single image | |
* @param {Object} attrs - Image element attributes | |
* @returns {Promise} {elm: img} | |
* @example | |
* loadImage({ src: 'foo.jpg', alt: 'foo' }) | |
* .then(obj => console.log(obj.elem)); | |
*/ | |
export function loadImage(attrs) { |
This file contains hidden or 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
/** | |
* Creates video and load it | |
* @param {Object} videoAttrs - Video element attributes | |
* @param {Object} sourceAttrs - Source element attributes | |
* @returns {Promise} {elm: video} | |
* @example | |
* loadVideo({autoPlay: false, controls: true}, {src: 'foo.webm', type: 'video/mp4'}) | |
* .then(obj => console.log(obj.elem)); | |
*/ | |
export function loadVideo(videoAttrs, sourceAttrs) { |
This file contains hidden or 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
//https://stackoverflow.com/a/52357595/2690846 | |
// usage: let frames = await extractFramesFromVideo("https://example.com/video.webm"); | |
async extractFramesFromVideo(videoUrl: string, fps=3) { | |
return new Promise(async (resolve) => { | |
// fully download it first (no buffering): | |
let videoBlob = await fetch(videoUrl).then(r => r.blob()); | |
let videoObjectUrl = URL.createObjectURL(videoBlob); | |
let video = document.createElement('video'); |
OlderNewer