Few weeks ago, I stumbled upon a cute little Javascript textmode library to generate text mode stuff inside the browser using the canvas element. Of course, I had to try to do something with it, and I quickly came up with this simple but efficient character and color cycling effect. You can see it in action here.
varscreenManager;varcharacterIndex=0;varcolorIndex=0;// Define character and color arrays vararrayCharacters=[0x5c,0x7c,0x2f,0x2d];vararrayColors=[0xf,0xb,0x9,0x1,0x9,0xb];// The font that we will usevarsourceFont=newImage();sourceFont.src="font.png";/*****************************************************************************//* Initialization *//*****************************************************************************/functioninit(){// Initialize the textmode libraryscreenManager=newTextModeScreen(40,25,"mainCanvas",sourceFont);// Call our main loop at 10fpssetInterval(mainLoop,1000/10);}/*****************************************************************************//* Main Loop *//*****************************************************************************/functionmainLoop(){for(offset=0;offset<screenManager.charsHigh*screenManager.charsWide;offset++){// Write character and color data screenManager.charBuffer[offset]=arrayCharacters[characterIndex];screenManager.colourBuffer[offset]=arrayColors[colorIndex];// Increment the color indexcolorIndex=(colorIndex+1<arrayColors.length)?colorIndex+1:0;}// Increment the character indexcharacterIndex=(characterIndex+1<arrayCharacters.length)?characterIndex+1:0;// Print footer textscreenManager.print(0,24," Simple character+color cycling example ",0x1e);// Render the textmode screen to our canvasscreenManager.presentToScreen();}