Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

I've been playing around with Chrome's experimental HTML-in-Canvas API (I use it to create my videos), and I wanted to see if I could make text-selection work on a curved surface by moving the underlying element around on pointermove. It works pretty well!

118,152 görüntüleme • 7 ay önce •via X (Twitter)

54 Yorum

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Live demo: (needs Chrome Canary with the canvas-draw-element flag. Source:

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Of course, this means you can add shaders (again, Chrome Canary with canvas-draw-element flag)

Nick Siscoe profil fotoğrafı
Nick Siscoe7 ay önce

Could make for a cool CRT style window effect

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

😁

Nick Siscoe profil fotoğrafı
Nick Siscoe7 ay önce

Ope lol

Andy Hawkes profil fotoğrafı
Andy Hawkes7 ay önce

The obvious next move is to put another canvas element within that HTML?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

You joke, but I already do this. In the videos I make, the frames of the video of me are pulled out using the VideoDecoder API and written to an inner canvas.

Una 🇺🇦 profil fotoğrafı
Una 🇺🇦7 ay önce

Nice, I've been playing around with this a little too in my spare time. I've noticed/reported an unfortunate quality difference between content within a canvas vs. a DOM overlay. Have you run into that as well?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Ohhh is it a resolution issue? I haven't experienced that in 2d canvas when creating my dev video things, but I've been running an old Chromium build since a bunch of stuff has broken since then and I haven't had time to investigate it.

Una 🇺🇦 profil fotoğrafı
Una 🇺🇦7 ay önce

I don't think so -- it's something I've noticed in most HTML in canvas demos, like a slight 1px blur but I can't unsee it.

Marko profil fotoğrafı
Marko7 ay önce

That's awesome. I didn't even know HTML in canvas is a thing. woa

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Well, it isn't yet. This is an API in progress, in Canary, behind a flag.

Marko profil fotoğrafı
Marko7 ay önce

Ok, then I'm one of the first, that's great, thanks.

EmaDev profil fotoğrafı
EmaDev7 ay önce

What is html-in-canvas API??? 😵 I need it!

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

it's experimental, and the prototype is only in Chrome Canary behind a flag

EmaDev profil fotoğrafı
EmaDev7 ay önce

Really happy for that! Il will unlock a lot of things 💣

Taylor Plewe profil fotoğrafı
Taylor Plewe7 ay önce

Was literally just looking into how one would go about making a pixelated website. This is the exact API I was looking for

Jamie Birch profil fotoğrafı
Jamie Birch7 ay önce

Is there anything like a measureText() API with it that would make the new pretext library redundant on Chrome?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

It's been in all browser engines over a decade That pretext library uses it.

Jamie Birch profil fotoğrafı
Jamie Birch7 ay önce

I’m asking about something else – measureText() only handles ctx.font, and not line wrapping, etc., right? So does HTML-in-canvas offer anything more powerful on that front? Or do you still have to wait for the next animation frame, meaning it’s no better than HTML ex-canvas?

Jamie Birch profil fotoğrafı
Jamie Birch7 ay önce

I mean, does HTML-in-canvas give any way to synchronously get the metrics of wrapping text, without having to wait for the next animation frame?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

You can already do this in HTML. You don't need to wait until the next frame to call getBoundingClientRect etc etc. It will give you current data. You should avoid interleaving layout reads & writes of course, because that's a slow path. You can always use an iframe.

Jamie Birch profil fotoğrafı
Jamie Birch7 ay önce

Yeah, but getBoundingClientRect() forces a layout flush, doesn’t it? Or is that what you are referring to with the slow path? Iframe, huh… 🤔 I wonder if any prior art has explored that.

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Right, getBoundingClientRect will force a layout _if_ layout is stale. Otherwise it won't. But, measureText is performing layout work too, that's how it works. The key is to avoid interleaving layout reads & writes, or isolate their impact.

El Valiente profil fotoğrafı
El Valiente7 ay önce

I am personally very excited about this. Like Christmas excited.

Paul Calcraft profil fotoğrafı
Paul Calcraft7 ay önce

@itseieio you might like this!

月球背面 🌑 Moonvy profil fotoğrafı
月球背面 🌑 Moonvy7 ay önce

Finally can take screenshots in the browser

Tim Miller profil fotoğrafı
Tim Miller7 ay önce

Woah! What an incredible tool this could be 😱

nofunsir profil fotoğrafı
nofunsir7 ay önce

html-in-canvas smells an awful lot like another sneaky way to force ads on the user agent.

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

How?

nofunsir profil fotoğrafı
nofunsir7 ay önce

Canvas-based rendering moves the web toward a "black box" model where the publisher has control over what is displayed and tracked, and the user agent has very little. Blocking moves from element- to pixel-based. See also: canvas fingerprinting.

Ebiko profil fotoğrafı
Ebiko7 ay önce

does that mean I can wrap my whole website into an canvas using canvas html and then create a video stream based on that canvas using the canvas as a context? Thats interesting. That means I can literally build a remote controllable and viewable website using Jitsi :D

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

You can definitely record the canvas content to video. That's how I make these:

Andrew Wiseman profil fotoğrafı
Andrew Wiseman7 ay önce

Haven't peeked behind the scenes at this, but the html page transformations reminded me of the new renderings available on xkcd...

Bora Turan profil fotoğrafı
Bora Turan7 ay önce

cool, but need also webkit support to spend time on it

familiar horse cop profil fotoğrafı
familiar horse cop7 ay önce

this will always be peak:

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Put it on a sphere, then I'm interested

Marko profil fotoğrafı
Marko7 ay önce

Sorry again, but I didn't get how this feature helps with your video creation? Are you using css to do animation (above) and somehow coordinate timing wtih rendering of video, video drives animation?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Yep, it means I can use web tech to do things like syntax highlighting, and web animations for animations. It also means my demos of things like CSS shape() can be 'live' demos. I'm sure someone can do all this in a video editor, but the web is what I know best.

Marko profil fotoğrafı
Marko7 ay önce

Nice stuff Thanks! I'll take a look at this. Ironically you made me install Chrome Canary lol

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Haha I won't show my boss this

Gustav ❖ profil fotoğrafı
Gustav ❖7 ay önce

Yooo

Faisal-Aldosari profil fotoğrafı
Faisal-Aldosari7 ay önce

So other than just being able to do this, what purpose does it have?

Koolala profil fotoğrafı
Koolala7 ay önce

It's warping the DOM inputs to match?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Nah, I just apply a simple x/y translate on the element so the bit under the pointer is correct

Tom Bielecki profil fotoğrafı
Tom Bielecki7 ay önce

@TheRealKoolala Does that mean you could have an iOS Glass style of button ("element") where the text and pointer deform with diffraction effects?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

@TheRealKoolala Yep!

Anubhav Gupta profil fotoğrafı
Anubhav Gupta7 ay önce

Does this mean that i can render half of my html normally and one or more portions of my html using canvas(perf intensive)?? This is awesome. Do you see any perf gains when rendering in canvas vs html ?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Rendering HTML in a canvas will be slower than rendering it normally, as the browser can't make particular optimisations

Anubhav Gupta profil fotoğrafı
Anubhav Gupta7 ay önce

Wow, this is totally opposit from what i was assuming, can you also share an example of an optimization?

Jake Archibald profil fotoğrafı
Jake Archibald7 ay önce

Not rendering things out of view, rendering only changed parts, optimising texture size

Anubhav Gupta profil fotoğrafı
Anubhav Gupta7 ay önce

Thanks for this information.

Surya Dantuluri profil fotoğrafı
Surya Dantuluri7 ay önce

super cool

Soham profil fotoğrafı
Soham7 ay önce

Canvas being canvas

Benzer Videolar