Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Neat! :D

Minified JavaScript :(

But from one Simon (canvas lover) to another I decided to chewing through the plastic bars of minification to see what was going on. In your loop you're doing:

    beginPath()
    arc()
    fill()
You could get away with nothing but arc() and moveTo() in your loop instead and make it a bit more efficient on slower (mobile) devices, because only one new path has to get created.

Your moveTo's x coordinate is going to need to be offset by the radius since thats where each starts. So it would look something like this:

    s.beginPath()
    loop start
        s.moveTo(10 * b + 5 + 4, 10 * c + 5)
        s.arc(10 * b + 5, 10 * c + 5, 4, 0, 2 * Math.PI, d)
    loop end
    s.fill()
I didn't try out the code, just typing in the open air here, but it should work.


Hi fellow Simon, I do link to the code on github, for anyone that wants to look at it in full. Here it is again: https://gist.github.com/3889013

That's a great tip! I love little optimizations like that, thanks for the input. :)


I just tried this, and it doesn't work as expected. With a stroke it might, but with fill, it leaks.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: