logoalt Hacker News

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

756 pointsby dlazarolast Saturday at 1:25 PM159 commentsview on HN

For HTML Day 2025 [1], I made a web service that displays the current sky at your approximate location as a CSS gradient. Colours are simulated on-demand using atmospheric absorption and scattering coefficients. Updates every minute, without the use of client-side JavaScript.

Source code and additional information is available on GitHub: https://github.com/dnlzro/horizon

[1] https://html.energy/html-day/2025/index.html


Comments

ryandrakelast Saturday at 2:07 PM

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...

show 16 replies
throwanemlast Saturday at 1:55 PM

> 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.

show 3 replies
nhinck3last Saturday at 2:21 PM

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

show 2 replies
cloudfudgelast Saturday at 7:36 PM

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?
show 2 replies
jclarkcomlast Saturday at 11:49 PM

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...

mournerlast Saturday at 5:33 PM

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

show 2 replies
esafaklast Saturday at 3:15 PM

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

101008last Saturday at 3:26 PM

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

jaharioslast Saturday at 11:19 PM

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...

SeanAndersonlast Saturday at 4:49 PM

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.

xatttlast Saturday at 3:27 PM

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

show 1 reply
fmbblast Saturday at 6:37 PM

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!

joeyhlast Saturday at 9:26 PM

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

bigwheelslast Monday at 3:37 PM

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 :)

cgijoelast Saturday at 4:28 PM

Ooh, how about this as a live desktop wallpaper!

show 1 reply
nistenlast Saturday at 2:17 PM

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

ianbickinglast Saturday at 2:14 PM

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

I wonder what it would take to account for weather?

show 1 reply
fastasucanlast Sunday at 8:42 AM

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.

card_zerolast Saturday at 5:10 PM

Useful, saves me looking at the thing.

leokennislast Sunday at 10:50 AM

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”.

kylegalbraithlast Sunday at 6:02 AM

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.

yonatan8070last Saturday at 7:09 PM

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?

Biganonlast Sunday at 9:16 AM

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

ryukopostinglast Saturday at 10:30 PM

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

j45last Saturday at 9:33 PM

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

mushufasalast Saturday at 3:57 PM

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

show 2 replies
CodeVerseExlast Sunday at 4:39 PM

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.

jama211last Monday at 4:55 AM

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

tcumuluslast Sunday at 8:29 AM

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!

dddgghhbbfblklast Sunday at 3:45 AM

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!

tincolast Saturday at 7:14 PM

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?

show 1 reply
meatjuicelast Sunday at 3:00 AM

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.

cosmicgadgetlast Saturday at 4:19 PM

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

dehuggerlast Saturday at 8:22 PM

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.

djoldmanlast Saturday at 2:41 PM

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

    <body style={{backgroundColor: bottom}}> </body>
is not needed.
show 1 reply
mgdmlast Saturday at 8:29 PM

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.

chrzlast Sunday at 10:14 PM

Fully black web page for me here. Well its correct

DonHopkinslast Saturday at 4:04 PM

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

show 1 reply
mcintyre1994last Sunday at 8:14 AM

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

jama211last Sunday at 7:10 AM

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

stephenlflast Saturday at 1:52 PM

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

show 1 reply
jhardy54last Saturday at 3:06 PM

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

gdubslast Saturday at 3:11 PM

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

show 1 reply
ComputerGurulast Sunday at 3:47 AM

Ahhh you’re not taking light pollution into account!

cwmoorelast Saturday at 7:13 PM

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

verelolast Saturday at 8:13 PM

Feels like this would be great for fake skylights…

mlhpdxlast Saturday at 2:24 PM

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

show 1 reply
sudostephlast Saturday at 8:08 PM

Looks pretty Carolina blue to me. Good job.

lazystarlast Sunday at 3:37 AM

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

nnnnicolast Saturday at 1:58 PM

incredible <3 not much else to say

🔗 View 11 more comments