Show HN: The current sky at your approximate location, as a CSS gradient

dlazaro | 788 points

Awesome. I remember much earlier in my career I was working on a 3D turn-by-turn navigation software, and one of my tasks was to draw the sky in the background. The more senior guy on the team said, just draw a blue rectangle during the day and a dark gray one at night and call it job done. Of course, I had to do it the hard way, so I looked up the relevant literature on sky rendering based on the environment, latitude, longitude, time of day and so on, which at the time was Preetham[1] ("A Practical Analytic Model for Daylight"), and built a fully realistic sky model for the software. I even added prominent stars based on a hard-coded ephemeris table. It was quite fast, too.

Well, the higher ups of course hated it, they were confused as to why the horizon would get hazy, yellowish, and so on. "Our competitors' skies are blue!" They didn't like "Use your eyes and look outside" as an answer.

Eventually, I was told to scrap it and just draw a blue rectangle :(

All that to say, nice job on the site!

1: https://courses.cs.duke.edu/cps124/fall01/resources/p91-pree...

ryandrake | 22 days ago

> the little-known meta http-equiv="Refresh" HTML tag

Oh, don't mind me, I'll just be over here in the corner laughing ruefully as my bones crumble to dust: back when I started, if you wanted a page to refresh on its own, this was the only way.

Beautiful work! A splendid example of formal minimalism at its best.

throwanem | 22 days ago

Opened this up and sat there for a good 20 seconds waiting for something to happen... only to remember it's midnight here.

nhinck3 | 22 days ago

Very cool. We are launching a sensor that mounts on the inside of your window and measure the sky color for a small cone of the sky and transmits this to our skylight and window fixtures inside (see innerscene.com) so they can replicate exactly the same thing indoors. You could potentially use a computer monitor to do this, but it generally doesn't provide great light due to using RGBs instead of wide-spectrum sources.

One issue with the current code is it doesn’t model clouds, haze, or smoke so the rendered sky can differ from what you see outside (numerous HN comments notice this). You can partially correct for this by using semi-realtime satellite imaging but hard to get super accurate which is what pushed us to develop our own sensor. There are various CCT sensors on the market already but they only measure directional+diffuse+reflected light which is typically ~7500k but the sky color goes up to 40,000k.

Here is a plot showing the color of the sky as it changes during the day from real sensor readings. Each one is 30s apart, so it change change quickly. https://www.innerscene.com/built_pages/cs_specsheet/cct/cct_...

A bit more info as well: https://www.innerscene.com/SpecHelp/CircadianSky/cct/cct.htm...

jclarkcom | 22 days ago

As an old-timer who's not up on all the latest whiz-bang web stuff, I have to ask what is the astro/cloudflare/wrangler magic that allows the following to work:

  const { latitude = "0", longitude = "0" } = Astro.locals.runtime.cf || {};
I gather you're using some cloudflare feature wrapped in astro to provide lat/long but I don't see the actual plumbing that gets it to you (and I did try to spelunk through a decent amount of documentation to find it). Can you elaborate?
cloudfudge | 22 days ago

Author of Suncalc here — this is exactly the kind of stuff I love to see my code being used in, thanks for sharing!

mourner | 22 days ago

More sophisticated than I expected. It relies on a research paper: https://github.com/ebruneton/precomputed_atmospheric_scatter...

esafak | 22 days ago

Put my phone against the window and I had to call over my wife to come to check it: it matches 100% (clear sky right now). It's amazing, congratulations

101008 | 22 days ago

I refreshed the page, enabled js, refreshed again and again and finally I gave up thinking it is not loading because it was hugged to death. While reading the comments here it dawned on me that it was just a black background because it is night outside and the paged worked fine from the start...

jaharios | 22 days ago

Oh nice, this is actually something I very specifically wanted for https://ant.care/! I was trying to have the background sky for the ant farm be reflective of the user's current environment, but I didn't do anything more than a naïve approach. Maybe I'll work on adopting your approach at some point :) Still a bit torn on if the whole thing should be Rust/WASM or just the core simulation in Rust and defer as much as possible to JS/HTML.

SeanAnderson | 22 days ago

This would be an awesome background for a smart home dash!

xattt | 22 days ago

It’s way too dark for this time of year at this time of day here at 60 degrees north.

But it looked very cool earlier today when it matched!

fmbb | 22 days ago

Ooh, how about this as a live desktop wallpaper!

cgijoe | 22 days ago

This reminds of of a web page that did this for Ithaca NY circa 1995. The page was a static hardcoded shade of grey.

joeyh | 22 days ago

i put my laptop next to the window and it was spot on wtf

what got me the most is opening chrome dev tools and seeing nothing there

nisten | 22 days ago

I'm around so much wildfire smoke lately that my sky expectations have changed...

I wonder what it would take to account for weather?

ianbicking | 22 days ago

Useful, saves me looking at the thing.

card_zero | 22 days ago

This might be a stupid question, but is it the background of https://html.energy/html-day/2025/index.html that shows the current sky? I am a bit confused since neither the post or the github repo says so outright.

Edit: I think its this link: https://sky.dlazaro.ca/ OP - put it in the HN post and first on your github repo! Good work.

fastasucan | 21 days ago

Tid bits like this are why HN is still the best corner of the internet most of the time.

This is really cool. I’ll probably see if I can make it my new tab background in Chromium.

kylegalbraith | 22 days ago

Very cool, though I opened it at night so it's just black. Is there a way to adjust the time it renders to see what it would look like at different times?

yonatan8070 | 22 days ago

Should anyone appreciate it, this Shortcut for your iOS/iPadOS device will set your wallpaper to the current sky based on this nice tool:

https://www.icloud.com/shortcuts/c8ba254a0272453cbe39357b144...

Just make sure that your last (or only) iDevice Home Screen is set to type “image”.

leokennis | 21 days ago

Would be cool if it considered current weather conditions. The sky is presently much grayer than what the site showed me.

ryukoposting | 22 days ago

Not often does a project make me think "adorable", and it's a compliment. Just lovely.

Biganon | 21 days ago

would love this to be a desktop background -- linux or macOS

mushufasa | 22 days ago

Tried this out now- it's totally gray outside as far as the eye can see, but the sky.dlazaro.ca shows it as clear blue. I wonder where the disconnect / divergence is originating from! Super neat idea in concept :)

bigwheels | 20 days ago

Neat tool, would love to be able to set the location when the registered IP location isn’t accurate.

j45 | 22 days ago

21pm in The Netherlands, the sky is a clear blue down to a baby pink right now, however the app shows a black to dark red. Other people are saying it matches exactly for their location so maybe there's some sort of bug?

tinco | 22 days ago

That is awesome but now I want to check what my SF bros see when they look up.

cosmicgadget | 22 days ago

I'll have to check this out tomorrow. I can tell you that black is not very accurate for my current conditions (midnight in Manhattan) but curious to see how it does in the day!

dddgghhbbfblk | 22 days ago

This project looks amazing and fun. However, the website did not seem to take the cloudy weather at my current location into account, which is a bit of a disappointment.

meatjuice | 22 days ago

Very cool! Might be interesting to combine this with cloud data or sunset forecast data from Sunsethue to create some sort of sky/sunset simulation. Well done!

tcumulus | 21 days ago

@dlazaro, I believe that style={{backgroundColor: bottom}} is not needed in:

    <body style={{backgroundColor: bottom}}> </body>
is not needed.
djoldman | 22 days ago

Very cool concept. Would be great if there’s an option to tweak the gradient before copying, so devs can match it exactly to their design needs.

CodeVerseEx | 21 days ago

Is this all done server side? I was shocked to inspect the page to discover zero js or even a stylesheet. Not so much as a single div. Very impressive.

dehugger | 22 days ago

I have been meaning to do it for ages! I got as far as finding a paper on the topic and reading it and then forgetting all about it. Nice work.

mgdm | 22 days ago

Why doesn't it respect dark mode??? ;)

DonHopkins | 22 days ago

This would be cool on a fake window for your house, like a screen in a basement

jama211 | 21 days ago

Fantastic. I’ve always wondered why the sky wasn’t blue around the horizon. Fascinating stuff.

stephenlf | 22 days ago

Super neat. Looking forward to checking out your implementation and learning about this!

jhardy54 | 22 days ago

My sky is blue and orange right now though and your site shows black.

2OEH8eoCRo0 | 21 days ago

Well, that's delightful. Works really well here in the Pacific Northwest :)

gdubs | 22 days ago

This is really cool! And from skimming your code, TIL about Math.hypot!

mcintyre1994 | 21 days ago

Ok this is incredible, it was exactly right, I did a double take!

jama211 | 22 days ago

I like this, but I’m newly concerned about the unitary horizon.

cwmoore | 22 days ago

Fully black web page for me here. Well its correct

chrz | 21 days ago

Ahhh you’re not taking light pollution into account!

ComputerGuru | 22 days ago

Which direction am I looking? Deeper blue to the north.

mlhpdx | 22 days ago

Feels like this would be great for fake skylights…

verelo | 22 days ago

Looks pretty Carolina blue to me. Good job.

sudosteph | 22 days ago

incredible <3 not much else to say

nnnnico | 22 days ago

sunsetting in the monroe, wa area. only a month left to live out here, gonna miss it dearly

lazystar | 22 days ago

Bit darker blues, please!

sheerun | 22 days ago

Beautiful, thank you!

michelreij | 22 days ago

Curious why a celebration of HTML needed a full stack javascript framework?

i_love_retros | 22 days ago

Works in Hawaii.

therealfiona | 22 days ago

Seems to work :)

hoppp | 22 days ago

that is really cool, thanks for sharing

natewww | 22 days ago

how i missed this small hn posts. thanks

siva7 | 22 days ago
[deleted]
| 22 days ago

[dead]

skyzouwdev | 21 days ago

[dead]

aqua_worm_hole | 21 days ago