The measurement file says 1.571. The stylesheet says 1.57.
2 months ago
Everything on a screen is flat. The shadow under a button is a grey smudge somebody nudged around by eye. Ambient CSS is one file you add to a web page. You put a light on the page, and every edge works out its own shadow from where that light is. Those shadow numbers came out of Blender, the free 3D program animators use.
Ask about this presentation
Chapters
0:00ambientcss · shadows solved from one light
0:18These two frames are the same page, one click apart
0:36The blur under a button is a number somebody chose
0:48Five shadow bands, and every distance in them is arithmetic
1:18The shadow numbers come out of a Blender render
1:52The measurement file says 1.571. The stylesheet says 1.57.
2:15The panel’s colour and the lamp’s colour are two different settings
2:28There is no key and no account to set up
2:42You set the light once, and every edge follows
Show transcriptHide transcript
Everything on a screen is flat. The shadow under a button is a grey smudge somebody nudged around by eye. Ambient CSS is one file you add to a web page. You put a light on the page, and every edge works out its own shadow from where that light is. Those shadow numbers came out of Blender, the free 3D program animators use.
The project’s demo has three discs: one dished in, one flat, one domed out. You tell the container where the light is, then you tag each box inside that container. One click moves the lamp to the other corner and turns the lamp down. The bright side of every disc swaps over, the shadows swing across, and the whole panel goes dark.
Where do the numbers in a shadow come from? Usually from a person. Somebody types a number, looks at it, types a bigger one, and stops when it looks right. That is a taste decision. This file answers that question differently.
Here is one box with Ambient CSS on it. Its shadow is five separate bands stacked on top of each other, and each band draws a different part of the edge. First, the shadow the box throws on the page. Then a bright band and a dark band along the bevelled edge, the cut around the rim. Then two softer bands just inside them. And here is what the file actually says for that drop shadow. Every distance in it is arithmetic: which way the light points, multiplied by how high the box sits at six point eight pixels a level, plus how thick it is at three point eight pixels a level.
So somebody had to know that six point eight pixels. The project ships the lab that made it. The author built the part in Blender and lit it on a plain studio backdrop. One command renders the reference parts, one picture each. A second command measures how the light fades off every edge in those renders, fits a curve to each one, and writes the answers into a single file. That calibration setup is about half of what is in the project. And back in the file a browser downloads, the drop shadow carries a comment naming the exact lab note its numbers came from.
Here is the whole round trip, closed on one band. The measurement file says the bright band along a bevelled edge is one point five seven one times the main lamp, plus zero point eight five one times the softer fill lamp, minus one point zero three two. The file a browser downloads says one point five seven, zero point eight five, one point zero three. They are the same three numbers, rounded. That constant is the answer to a measurement, and the measurement ships beside the constant.
The same rule covers colour. You give the panel its own colour, and everything inside the panel takes that colour: the grooves and the knobs. Turn the lamp red and the whole scene reads red, while the panel’s own colour sits where you left it.
It installs in one line, and the licence is MIT, so you can use this in anything. The version lives on npm, where these packages get published. Right now it is three point zero point one. The docs site has a kit builder that assembles a knob and hands you the file.
That hardware panel was one object shown twice: once traced ray by ray in Blender, once drawn by a browser. That is kikkupico slash ambientcss, on GitHub. New repo tomorrow.
Up next
6:49Hide the tests from your coding agent? StrongDM's holdout idea, tested on Claude Code
@github-trending
3 weeks ago
0:51Claude Code built a machine to explain prompt caching
@github-trending
1 month ago
10:10reladraw draws your diagram from where you say the boxes go
@github-trending
1 month ago
7:27Lap photo manager finds photos by what's in them, offline
@github-trending
2 months ago
9:04Spirula Studio does Gaussian splatting on any graphics card
@github-trending
2 months ago
8:50Univer puts a spreadsheet, document editor and slides in your app
@github-trending
2 months ago
18:13i-have-adhd, ponytail, and 7 more skills that make your agent stop explaining itself
@github-trending
2 months ago
7:57Homebrew BrewUI runs every brew command in a clean shell
@github-trending
2 months ago
8:35fugleramme draws the birds in your garden on an e-ink frame
@github-trending
2 months ago
9:01Open Code Review: Alibaba open-sourced the code reviewer it validated on a million real tasks
@github-trending
2 months ago
3:03Portless refuses to touch eight shapes of command, and says why for each
@github-trending
2 months ago
2:59Six questions every connector answers
@github-trending
2 months ago