This branch introduces one major and two minor performance improvements:
Use one Path for each call render() call, instead of creating new Paths for each circular snowflake. This necessitated a slight refactor, which separates the image-based and path-based drawing routines into separate methods. The check for snowflake image presence is now only done once per render call, instead of once per snowflake. This should provide the most significant improvement on lower-end hardware and in cases with a large number of snowflakes.
Use for..of loops instead of forEach when updating snowflakes position and rendering them. I referred to the benchmark here.
Store Math.PI * 2 as a constant only calculated once per build. This avoids rerunning this multiplication every time we render a snowflake.
I'm working on supplying quantitative benchmark results, but I'm not sure of a good way to present that; if anyone has any ideas I'd love to hear them out to help get this merged!
This branch introduces one major and two minor performance improvements:
render()
call, instead of creating new Paths for each circular snowflake. This necessitated a slight refactor, which separates the image-based and path-based drawing routines into separate methods. The check for snowflake image presence is now only done once per render call, instead of once per snowflake. This should provide the most significant improvement on lower-end hardware and in cases with a large number of snowflakes.I'm working on supplying quantitative benchmark results, but I'm not sure of a good way to present that; if anyone has any ideas I'd love to hear them out to help get this merged!