Re:Show HN: Wiv.js – A library for a more wiggly div
by jjkaufman on Tuesday December 25, 2018 @11:33PM
(#18760534)
Thank you for the thoughtful code review. It is already running smoother
https://github.com/jjkaufman/wiv.js/pull/5 if you are curious
Re:Show HN: Wiv.js – A library for a more wiggly div
by PavlovsCat on Saturday December 29, 2018 @02:19PM
(#18785204)
Awesome! You're welcome :)
And don't set unneccessary canvas state, this should happen only once per draw loop iteration: [edit, actually, as I said above, the canvas contexts remember it individually, so do this once in initWiv(), and not in the draw loop at all, yay!]
That's all just at first glance, but I bet you, this would help with slow laptops and whatnot :) Such "small" things really add up when you do them 60 times per second * number of borders. I don't know if setting the canvas width or height to the value it has anyway to clear it (instead of clearing/drawing a rectangle explicitly) is still a useful thing to do, but you might try that as well.