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

3 days ago (sky.dlazaro.ca)

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

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

  • This is why specifications are important, and why design is important.

    The reality is that we have certain conventions that are immediately understandable, and that too much visual complexity results in confusion rather than clarity.

    If the sky is hazy white when I expect it to be blue, I'm confused as to whether it's the sky or if the map is still loading. It's adding cognitive complexity for no reason. Stars similarly serve no functional purpose at night.

    What you built sounds great for an actual planetary view like Google Earth. And it sounds fun to build. But it's an anti-feature for a navigation view. When you're navigating, simplicity and clarity are paramount. Not realism.

  • A past coworker who worked on Cobalt[1] told me that they spent entirely too much time implementing stars in the sky of the game with some amount of real(ish) star system physics behind them.

    I can understand people removing polish things like that if there are usability concerns, but those small things add up to a lot in an end product and are a joy to find and explore.

    1: https://en.wikipedia.org/wiki/Cobalt_(video_game)

  • Whipping down the innovator with the stupidity whip. Great management

    • It sounds like the developer spent a lot of time implementing something that nobody wanted. Drawing the sky accurately may be cool, but it wasn't required in this case. It's also not innovation. It's been done before.

      This is like if you were renovating your house and the drywall guy spends a huge amount of time building up round corners, but you just wanted regular square corners. Then on some drywall forum they're bitching about how "all clients are stupid" or something.

      1 reply →

    • This is a wildly unprofessional attitude. Programmers are craft(wo)men. They employ their craft toward creating things people pay them to create.

      We aren't painting sistine chapels, we are running the plumbing in the sistine chapels basement. The job doesn't exist to give you emotional fulfillment. A mason doesn't insist that a client who needs a warehouse must pay him to spend a week detailing corbelled brick cornices. He makes a CMU wall, in the cheapest and most efficient way that still gets the job done.

      It's profoundly disrespectful when we build monuments to our own ego instead of just getting the work done and it speaks to a professional immaturity of the highest order. That was one of the hardest lessons I learned as a fresh engineer and I see so often others that are just learning it. Sometimes people never learn it.

      1 reply →

    • I've been in the developer's shoes. I've also been in the manager's shoes.

      It's not that simple. There's possibly better ways to deal with it, but for safety-critical stuff (like a navigation display in a vehicle), simple is much, much better. In many cases, there's actually laws and liability stuff involved.

      I once spent six months, developing an "un-asked-for" WiFi control app for a digital camera, and had it nuked. It worked much better than the shipping app (which was enjoying a richly-deserved one-star rating in the app store).

      The considerations had a lot to do with the corporate Process (note the capital "P"), which I sidelined. I thought I could do better, but the people with the hands on the brake, thought different. I didn't kiss the right rings. That's a very real consideration in any corporation.

      As a manager, however, I did go to bat for employees that displayed initiative. In some cases, I was successful. In some cases, not so much.

      1 reply →

    • A foundational, core theme about making commercial software, that repeats over and over and I slowly got accustomed to is: companies really don't want these kinds of micro-innovations. 90% of companies are just looking at their competitors, making a checklist out of those products, and asking engineers to check the boxes and go home. They don't care about little details, about craftsmanship and polish, about lint warnings, about "oh, that's a nice touch," or even quality beyond "will the customer return the product?" They just want people to poop out software as fast as possible so everyone can get bonuses and drive around on their jetskis on Saturday.

      If you're the kind of developer who likes to "sand and finish the back side of the cabinet," either you need to find a very rare, special company, or do it at home as a hobby.

      6 replies →

  • Not even as an easter egg?

    You could've sold it with telling them Vincent Van Gogh's paintings had the location of stars accurately, you were inspired by those paintings to reproduce the sky color accurately.

  • Ironically, I'm in the South of England wih clear blue sky, and the site thinks I have a much darker and beautiful reddish sunset. Im fairness, it's probably only out by an hour if that.

  • The thing here is programming the job can be much more dull than programming the hobby. Occasionally (twice a decade) there can be a collision where you get to do something really cool like that at work. The higher ups want a realistic sky because their market research said it'll boost an OKR by 10 basis points. And then you are in luck!

    That said there are niches where jobs let you do cool stuff all the time. Hard to find. Probably why gaming jobs are notoriously underpaid and overworked.

  • That sounds really cool but I have to reluctantly agree with the senior: a cartoonish day/night sky is better than a half-implemented realistic one. I say “half-implemented” because it sounds as though yours didn’t account for local weather and cloud cover, which is reasonable but then incomplete. Even if you did, well, it’s turn-by-turn navigation. I expect the sky color to be selected for ideal contrast with the important UI elements to reduce the time spent looking at it while driving.

  • I’ve had similar issues at work where people really overdo something and it’s difficult. On one hand you never want to kill that joy and passion someone has. That’s a great characteristic. But projects have scopes and too often instructions like “just draw a blue rectangle” get ignored.

    • Totally. It was a harsh but needed lesson on the realities of getting work done in a commercial environment.

  • Yep, if you have to draw the Sun, you better draw it yellow. If you have to draw a cloudless day sky, you better draw it blue.

    That doesn't apply to every single instance of those, but if the sky isn't the focus of your application, a realistic one is just a distraction.

    • > Yep, if you have to draw the Sun, you better draw it yellow.

      This one always gets me in how dirty the sky must have been "back in the day" in order for people to see a yellow sun. I've never looked into what gas would be needed to make the sun look yellow, but it must have been hell to breathe.

      2 replies →

  • To be honest I don’t think anyone wants that kind of functionality - maybe in the satellite view but not in the vector map.

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

  • Of course, the "http-equiv" means that this tag is supposed to stand in for an equivalent HTTP header, so you could accomplish the same by sending a "Refresh: 60" header :)

  • Thank you! And umm, not to make you feel ancient, but I think I wasn't even alive yet when `setTimeout(() => location.reload(), ...)` first became widely available.

    • Oh, don't worry about it at all, and I don't just mean in my own case. Every generation learns to age graciously or otherwise, partly through experience, and for me it's a regular source of joy to see you young 'uns independently rediscover things I long since quit bothering to remember.

      1 reply →

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

  • Maybe someone smarter than me could add stars to the night sky, so it's not just black.

    • I was just thinking about how to slice up a star map projection, and apply it as an overlay. I don’t do such things often enough to do it quickly, although I can imagine how it could be achieved. I’d imagine someone working in game dev probably could whip up a mechanism for applying coordinates to a star map fairly quickly, but realizing it in pure CSS would probably require exporting all the slices to a folder as SVG squares that are labeled with coordinates, and then using a bit of JS to stitch it all together in the rendered page.

      1 reply →

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?

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

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

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

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

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.

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!

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

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

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

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

I wonder what it would take to account for weather?

  • That'd be a pretty large introduction of a dependency. The sky can be calculated with just lat/lon and the current date+time. Adding in weather would mean querying some external weather service.

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.

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?

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

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

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

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

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.

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

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!

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?

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!

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.

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.

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

    <body style={{backgroundColor: bottom}}> </body>

is not needed.

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.

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

  • There's two main reasons for this:

    - First and most impactful: as the earth curves down and away from the observer's horizon, your line of sight goes through a thicker slice of the atmosphere.

    Looking straight up you might have 100km of atmosphere until space (the distance is made up here, but I'm using the Kármán line as an arbitrary ruler), but looking out towards the horizon (assuming a perfectly spherical Earth), it's much, much more than that 100km, so the light will scatter off of (and/or be filtered by, depending on angle and time of day) more particles in the atmosphere, affecting the colour of the sky.

    - The compounding factor here is if there are environmental factors that boost the particle count in the air, and especially particles that'd stay in lower layers of the atmosphere. Where I am, we've been dealing with wildfire smoke of varying strengths for a few weeks. Today's gentle enough, but it's bad enough that my gradient goes from rgb(115, 160, 207) at the top of the sky to rgb(227, 230, 227) at the horizon (which is shockingly accurate).

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

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

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

  • A server is needed to calculate the sun's position from latitude + longitude + time, and then render the gradient. I could use HTML templating in some other language/framework, but I used Astro because that's what I'm familiar with and it's very easy to deploy to Cloudflare Pages.

    • it's beautiful. btw, could this be all done in client side js? didnt look at the implementation, probably server is used to resolve location?

      3 replies →