Building an Oddity on the Web for David Bowie featuring the Moon 🌓

In celebration of the 50th Anniversary of Space Oddity

Image for post
Image for post
This is Ground Control to Major Tom

Far Above the Moon

Image for post
Image for post

Forecasting the Moon

Simple transitions powered by Anime.js
SunCalc.getMoonIllumination(new Date())
SunCalc.getMoonPosition(new Date(), latitude, longitude)

Moon Phase

Phase        Name        
------- -----------------
0 New Moon
Waxing Crescent
0.25 First Quarter
Waxing Gibbous
0.5 Full Moon
Waning Gibbous
0.75 Last Quarter
Waning Crescent
let size = 200
let path = new Path()
if (phase >= 0.5) {
leftX = 0
} else {
leftX = size - (phase / 0.5 * size)
}
if (phase <= 0.5) {
rightX = size
} else {
rightX = size - ((phase - 0.5) / 0.5 * size)
}
path.add([size / 2, 0])
path.arcTo([leftX, size / 2], [size / 2, size])
path.arcTo([rightX, size / 2], [size / 2, 0])
path.pivot    = [size / 2, size / 2]
path.rotation = angle
let link = document.querySelector("link[rel*='icon']")
link.href = canvas.toDataURL("image/png")

Detecting The Moon

Image for post
Image for post
["Sky", "Cloud", "Atmospheric phenomenon", "Daytime", "Atmosphere", "Brown", "Cumulus", "Morning", "Celestial event", "Calm", "Evening", "Horizon", "Meteorological phenomenon", "Dusk", "Sunlight", "Dawn", "Space", "Moon", "Astronomical object", "Night"]
let data = canvas.toDataURL('image/jpeg', 1.0)data.replace('data:image/jpeg;base64,', '')

Thanks

David Bowie
David Bowie

Written by

I develop websites for rock 'n' roll bands and get paid in sex and drugs. Previously Silva Artist Management, SoundCloud, and Songkick. Currently: Available

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store