Created
December 21, 2018 16:30
-
-
Save rlemon/3cba9ac9116b6f3dbb91270438f2ba2d to your computer and use it in GitHub Desktop.
ascii starwars. data from https://www.asciimation.co.nz/
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
/* eslint-disable */ | |
import filmData from './filmData'; | |
const devTools = /./; | |
devTools.toString = function() { | |
this.opened = true; | |
}; | |
const linesPerFrame = 14; | |
const timeoutBase = 100; | |
let currentFrame = 0; | |
function renderFrame() { | |
console.log( '%c', devTools ); // test for dev tools. | |
if( !devTools.opened ) { | |
return setTimeout( renderFrame, 1000 ); | |
} else { | |
devTools.opened = false; | |
} | |
console.clear(); | |
let str = ''; | |
let timeout = timeoutBase; | |
for( let i = 0; i < linesPerFrame; i++ ) { | |
const index = ( linesPerFrame * currentFrame ) + i; | |
if( !i ) { // first line is the delay modifier | |
timeout *= parseInt( filmData[index], 10 ); | |
continue; | |
} | |
str += filmData[index] + '\n'; | |
} | |
console.log( '%s', str ); | |
currentFrame += 1; | |
setTimeout( renderFrame, timeout ); | |
} | |
renderFrame(); |
This file has been truncated, but you can view the full file.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment