04-23-2023, 06:03 PM
(04-23-2023, 05:10 PM)user328 Wrote: I refactored it as a JavaScript object, moved the encoded images into a separate file, and moved some Date and Math related functions to their respective built-in JavaScript objects.
Final revision.
I put the images back into the main script file, but at the very end. The reason I moved them out in the first place was because they take up a couple thousand lines in a text editor, which was very annoying, and there was no way to collapse them so I could see the code. Now they're tucked out of the way at the end of the file, and the whole shebang is conveniently packaged in one file.
In the first version I posted, you could change the diameter in CSS. I wanted to keep that ability, so I rewrote the render function. The results aren't completely satisfactory, as the small images become pixelated when scaled up. It is what it is.
Anyway, here's the complete JavaScript file, MoonPhase.js:
https://pastebin.com/BfLxgxvp
and here's the example usage in HTML:
https://pastebin.com/Scwt8Y6Y
That's all I'm gonna say about that.