This would be a great demo to see running in a responsive programming environment, ala Bret Victor's amazing Inventing on Principle talk ( http://vimeo.com/36579366 ). I want to be able to click on hex values and get a color picker that updates the demo in realtime, and be able to click on various magic numbers and drag a slider to change them. Incidentally, Bret Victor's talk was the starting point for Khan Academy'…
Notch trying jsFiddle
51–60 of 143 posts
Re: Notch trying jsFiddle
#52This would be a great demo to see running in a responsive programming environment, ala Bret Victor's amazing Inventing on Principle talk ( http://vimeo.com/36579366 ). I want to be able to click on hex values and get a color picker that updates the demo in realtime, and be able to click on various magic numbers and drag a slider to change them. Incidentally, Bret Victor's talk was the starting point for Khan Academy'…
Thanks for the livecoding link. I assume there's some overhead in constantly checking for and applying code changes - that's probably the reason for the lower frame rate.
Re: Notch trying jsFiddle
#53Re: Notch trying jsFiddle
#54Such a great example of what can be done in javascript/canvas. As it is, I was completely blown away by how little code it actually took to do that. My only gripe would be, why couldn't he have used descriptive variable names, so I can better go through and understand it? :-)
This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.
ctx = document.getElementById('game').getContext('2d');
pixels = ctx.createImageData(w, h);
ctx.putImageData(pixels, 0, 0);
EDIT: Thanks for the clarification!
Re: Notch trying jsFiddle
#55Why is the framerate poor even when I shrink the viewing area down 10x10? It seems to have the same stutter as the original large view. Is it because it's doing the same calculations but just showing fewer pixels?
Re: Notch trying jsFiddle
#56I enjoy that everything is procedural generated. The software rasterizing is pretty cool too. I don't mind that he uses short variable names, sometimes it's nice to have multiple lines line up perfectly. But this is just silly... for ( var x = 0; x
Re: Notch trying jsFiddle
#57As you may have anticipated, this demo runs at less than 1 frame per second on my Nexus 7. :/
In terms of per-pixel manipulation of a Canvas, it is very slow, even with javascript's (not very well supported) typed arrays. Simply put, multidimensional loops (unrolled or not) will always kill performance in JS with any significant dimensions. I learned this the hard way by trying to write a pixel-based GUI, and even that (with some crazy optimizations) could not render fast enough for all devices. If you are just doing blits, Canvas works very well (especially since this operation often uses the GPU).
For now, I think the best option is still WebGL, even though it is not widely supported yet, mobile devices are beginning to pick it up (Blackberry, for example).
Re: Notch trying jsFiddle
#58I enjoy that everything is procedural generated. The software rasterizing is pretty cool too. I don't mind that he uses short variable names, sometimes it's nice to have multiple lines line up perfectly. But this is just silly... for ( var x = 0; x
Can you explain why?
Re: Notch trying jsFiddle
#59I enjoy that everything is procedural generated. The software rasterizing is pretty cool too. I don't mind that he uses short variable names, sometimes it's nice to have multiple lines line up perfectly. But this is just silly... for ( var x = 0; x
Can you explain why?
Re: Notch trying jsFiddle
#60Earlier quoted context omitted.
This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.
Aren't the following canvas/javascript specific? ctx = document.getElementById('game').getContext('2d'); pixels = ctx.createImageData(w, h); ctx.putImageData(pixels, 0, 0); EDIT: Thanks for the clarification!