Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.

License

NotificationsYou must be signed in to change notification settings

GoogleChromeLabs/css-paint-polyfill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CSS Paint Polyfill demo

CSS Custom Paint / Paint Worklets polyfillnpm

A polyfill that brings Houdini'sCSS Custom Paint API and Paint Worklets to all modern browsers (Edge, Firefox, Safari and Chrome).

Performance is particularly good in Firefox and Safari, where this polyfill leverages-webkit-canvas() and-moz-element() for optimized rendering. For other browsers, framerate is governed by CanvastoDataURL() /toBlob() speed.

As of version 3, this polyfill also includes basic implementations ofCSS.supports(),CSS.registerProperty() and CSS unit functions (CSS.px() etc), which are injected in browsers without native support.

What are Paint Worklets?

Paint Worklets are JavaScript modules in which you can program custom graphics code. Once registered, they can be applied to elements using CSS:

An examplebox.js worklet:

registerPaint('box',class{paint(ctx,geom,properties){ctx.fillRect(0,0,geom.width,geom.height)}})

... registered and applied on a page:

CSS.paintWorklet.addModule('./box.js')varel=document.querySelector('h1')el.style.background='paint(box)'

For a more complete example, see thedemo.


Installation & Usage

<scriptsrc="css-paint-polyfill.js"></script><!-- or: --><scriptsrc="https://unpkg.com/css-paint-polyfill"></script>

Or with a bundler:

import'css-paint-polyfill';

... or with ES Modules on the web:

import'https://unpkg.com/css-paint-polyfill';

Contributing

SeeCONTRIBUTING.md.

To hack on the polyfill locally:

git clone git@github.com:GoogleChromeLabs/css-paint-polyfill.gitcd css-paint-polyfillnpm inpm start# open http://localhost:5000

css-paint-polyfill

About

CSS Custom Paint / Paint Worklet polyfill with special browser optimizations.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp