rich Posted September 5, 2013 Share Posted September 5, 2013 I won't post a screen shot as I don't want to spoil it But it's just a fun little thing I made tonight. http://sandbox.photonstorm.com/console.log/ Rezoner 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted September 5, 2013 Share Posted September 5, 2013 By the way, its not intro(250)in the console, but init(250)Funny idea; I smiled Sadly, its lagging so hard ^^ Quote Link to comment Share on other sites More sharing options...
p01 Posted September 5, 2013 Share Posted September 5, 2013 rich: I sent you this by mail, but better post this here:The idea is really cool. Too bad it's so slow to render.At work your canvasToConsole() method takes at 15-25ms on my i7 @ 3.4Ghz.The following version takes 12ms max. var canvasToConsole = (function(){ var txt = ""; for (var i = 50*30; i-- { txt += "%c "; if(!(i%50)) txt += "\n"; } return function() { var then = Date.now(); var id = mycanvas.contex.getImageData(0,0,50,30).data; var bah = [txt]; for (var i = 50*30; i-- bah.push("background: rgb("+id[i*4]+","+id[i*4+1]+","+id[i*4+2]+")"); console.clear(); console.log.apply(console,bah); console.log(Date.now()-then); }})();This also get rid of the blank/whitespace between each row of pixels.The go() method only needs to process the frame if (Date.now > t)I haven't been convinced by CODEF yet :\But at such a low resolution, you can probably use any framework. Thebottleneck is in console.log()Maybe a slightly lower resolution, and sharper graphics, would improvethe framerate and legibility.Or maybe, but that might be seen as "cheating", go for a simple: var canvasToConsole = function(){ var foo = "width: 150px; height: 90px; background: url("+canvas.toDataURL() +") 150px 90px"; console.clear(); console.log("%c ", foo);} // or anything similar. I haven't tried this, but I'm pretty surethis can work.Anyways, kudos for exploring new territories! Quote Link to comment Share on other sites More sharing options...
mwatt Posted September 5, 2013 Share Posted September 5, 2013 This is so.... creative, I guess is the best word. Cool is another good one. Quote Link to comment Share on other sites More sharing options...
rich Posted September 5, 2013 Author Share Posted September 5, 2013 Ok brand new version uploaded. This one includes p01's method of getting rid of the white lines! (looks MUCH better now) and I also added RLE so it's faster too as it has to generate a lot smaller logs. Also added option to toggle white/colour background - the white version helps visually. Added new refresh rate, instructions, music toggle. And... I'm done Quote Link to comment Share on other sites More sharing options...
mentuat Posted September 5, 2013 Share Posted September 5, 2013 no idea what epilepsy inducing madness I just experienced but I suddenly feel the need for a glow stick Quote Link to comment Share on other sites More sharing options...
p01 Posted September 5, 2013 Share Posted September 5, 2013 This one combines your RLE and my single getImageData + rgb colors, thus getting rid of a tons of functions calls.var canvasToConsole3 = function(){ var txt = ""; var prev; var args = [""]; var lfb = mycanvas.contex.getImageData(0, 0, 50, 30).data; for (var i = 0, j = 0; i < 1500; i++, j++) { if (!(i % 50)) // if(i && !(i % 50)) if don't like to start with a "\n" txt += prev = "\n"; var col = "background: rgb(" + [lfb[j++], lfb[j++], lfb[j++]] + ")"; if (col == prev) { txt += " "; } else { txt += "%c "; args.push(col); prev = col; } } args[0] = txt; console.clear(); console.log.apply(console, args);}; Quote Link to comment Share on other sites More sharing options...
rich Posted September 6, 2013 Author Share Posted September 6, 2013 Nice. Still flickers like a bad-ass though Quote Link to comment Share on other sites More sharing options...
triptych Posted September 6, 2013 Share Posted September 6, 2013 I dare you to use this example in a bug to the chrome folks to help fix the flickering. Quote Link to comment Share on other sites More sharing options...
rich Posted September 6, 2013 Author Share Posted September 6, 2013 I've literally just uploaded a new build, thanks to some feedback from twitter, which has got rid of the flickering almost entirely. Win! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.