News for hackers. Stuff that matters.
Re:The HTML-in-Canvas API origin trial by dvh on Friday October 23, 2026 @03:03AM (#50205378)
Wouldn't it make more logical sense to add canvas to html elements? I.e. checkbox.getContext("2d").fillRect(...)
Re:The HTML-in-Canvas API origin trial by azangru on Friday October 23, 2026 @04:07AM (#50205832)
Not if you need your html to adapt to the shape of a 3d object drawn in the canvas.

What you described is the CSS painting api (part of CSS Houdini)

Re:The HTML-in-Canvas API origin trial by aroman on Friday October 23, 2026 @03:15AM (#50205462)
I guess there are uses for that, but as a web game developer, that wouldn’t really help me. The killer feature is input and text rendering.
Re:The HTML-in-Canvas API origin trial by longor1996 on Friday October 23, 2026 @06:14AM (#50206719)
Or to add canvas operations (in?)directly to CSS!

Imagine being able to declare a list of paths with fill/stroke-paints to draw, filled in from attributes, variables and `calc()` values... one can only dream.

Re:The HTML-in-Canvas API origin trial by rafram on Friday October 23, 2026 @07:10AM (#50207171)
Already exists, albeit experimental and Chromium-only: https://developer.mozilla.org/en-US/docs/Web/API/CSS_Paintin...
Re:The HTML-in-Canvas API origin trial by longor1996 on Friday October 23, 2026 @10:16AM (#50209446)
Yes, I'm aware of this API, but that's exactly the problem (IMHO): it's an API, not built right into CSS itself, thus forcing you to use JavaScript.

What I really want is something along the lines of...

    @declare-some-shape MYSHAPE (ARGS) {
        /* tree of draw commands */
        /* can reference css animations, timelines, variables, etc. */
    }
    
    #my-div { content: draw-some-shape(MYSHAPE ARGS, TRANSFORM); }

    /* or, as some kind of pseudo-element: */
    #my-div::draw-some-shape(MYSHAPE) { ??? }
And yeah, fully aware that this looks abominable, but I'd rather this than stringly/DOMly generating SVGs or drawing in a canvas.
Re:The HTML-in-Canvas API origin trial by rafram on Friday October 23, 2026 @10:56AM (#50210137)
Absolutely not. You can already embed SVG as a data URI if you really, really want to (and you could probably implement this in SCSS with data URI output if you want to suffer doubly...).
Re:The HTML-in-Canvas API origin trial by longor1996 on Saturday October 24, 2026 @06:08AM (#50219758)
Which requires doing a ton of math/layout in JavaScript, since I need those shapes to go between, around and behind the normal HTML elements (working on games and editors here).

Doing all that is a colossal PITA, since SVGs aren't built to act as "fragments" I can arbitrarely draw with CSS or Canvas.

This new html-in-canvas API will alleviate the pain a bit, at least.