CSS-Doodle
202 points
1 month ago
| 5 comments
| css-doodle.com
| HN
https://yuanchuan.dev/an-introduction-to-css-doodle
binarygit
1 month ago
[-]
Author also has a blog post describing why he created this project and a high overview of what's happening behind the scenes

https://yuanchuan.dev/an-introduction-to-css-doodle

reply
dang
1 month ago
[-]
Thanks! I've added that link to the top text. There was also a past thread:

An Introduction to CSS-Doodle - https://news.ycombinator.com/item?id=40688055 - June 2024 (29 comments)

reply
AxiomLab
1 month ago
[-]
Always happy to see more tools for web-native generative art.

While I rely on Python/Cairo for heavier algorithmic brand assets, the immediacy of CSS for interactive patterns is hard to beat. The grid capabilities here look very robust for quick prototyping.

reply
gandreani
1 month ago
[-]
This is very cool. I have no idea how this one work. I'm guessing most of the magic is in the box shadow?

https://codepen.io/yuanchuan/pen/OJRqGvz

reply
lelandfe
1 month ago
[-]
Don't be fooled by the paucity of lines, that Codepen is of course pulling in an entire JS file: https://unpkg.com/css-doodle@0.34.7/css-doodle.min.js

If you inspect what's getting rendered, there's a sprite map expressed as a data URI that's doing most of the heavy lifting.

reply
wiether
1 month ago
[-]
Same

I don't understand how so few lines can produce so much different things.

And clicking on the background will just create a new random (?) background!

It seems that the aliases are doing a lot of work

reply
gandreani
1 month ago
[-]
The aliases we're tripping me up! I almost understand it now. Not sure what the @lp is doing
reply
smusamashah
1 month ago
[-]
As an aside but still relevant question, why is CSS preferred over JS when these days it can do lots of things like JavaScript and probably uses similar resources.
reply
Minor49er
1 month ago
[-]
CSS and JavaScript specialize in two very different areas and are commonly used in tandem
reply
soperj
1 month ago
[-]
You can do layouts with javascript?

Couldn't imagine ever wanting skip grid and flexbox for whatever has been concocted up for JS.

reply
tracker1
1 month ago
[-]
multi-window interfaces in the browser... simulating a desktop, or other user navigable environment such as in a game or simulation, where a user my want to customize their environment beyond a grid snap.
reply
ReaderOfRunes
1 month ago
[-]
The issue then becomes how do you make it accessible to screen readers? It's not impossible, just very tedious and requires cross browser and cross-device testing
reply
tracker1
1 month ago
[-]
While I understand the concern... Not everything ever made needs to be fully accessible to everyone.

That said, there are already aria labels for UI contexts such as modal windows. Desktop OSes are already multi-modal.

reply
k33n
1 month ago
[-]
1. This isn’t CSS. It’s a declarative JS drawing framework with CSS flavor to the syntax

2. Without actual CSS JavaScript wouldn’t be of much use for drawing much of anything unless you were just going to use canvasses and forego the DOM entirely

reply
sublinear
1 month ago
[-]
I agree. This seems like it would make more sense as a canvas library unless there's a use case I'm not understanding.
reply
Waterluvian
1 month ago
[-]
If I understand this, it’s all vector space. So it avoids one of the most irritating issues with working with canvas. I love not having to think about scale or resolution or aliasing.
reply
jtokoph
1 month ago
[-]
I think there is value in making it a declarative model
reply
webXL
1 month ago
[-]
Man, CSS looks absolutely nothing like it did when I started out. lol
reply