npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geometric-paint-worklet

v1.0.3

Published

A customizable CSS Paint Worklet that renders geometric figures to the background of any element

Downloads

7

Readme

geometric-paint-worklet

A customizable CSS Paint Worklet that renders geometric figures to the background of any element

Example with large thin borders


Table of contents

  1. What are CSS Paint Worklets
  2. How to use
  3. How to customize
  4. CSS Variables
  5. Examples

🧪 1. What are CSSPaint Worklets?

CSS Paint Worklets are part of the CSS Paint API (also known as “CSS Custom Paint” or “Houdini’s paint worklet”) which allow us to programmatically generate an image that we can then use on any CSS property that expects an image (background-image, border-image, ...).

[CSS Paint API article](https://developers.google.com/web/updates/2018/01/paintapi#:~:text=CSS%20Paint%20API%20(also%20known,default%20starting%20in%20Chrome%2065.&text=CSS%20Paint%20API%20allows%20you,CSS%20property%20expects%20an%20image. ) on the developers.google.com

⚠️ CSS Paint API features are experimental: Maybe you need to take a look at the CSS Paint Polyfill


📦 2. How to use

ℹ️ If you want to use a CDN, skip steps 1 and 2 and instead add <script scr="https://unpkg.com/geometric-paint-worklet"></script> to your index.html

  1. You can get the worklet js file from one of the following methods:

    1.1. Copy the dist/geomatric-paint-worklet.js file into your project

    1.2. Install with npm npm install geometric-paint-worklet

  2. Import the worklet file on your index.html head:

<script src="node_modules/geometric-paint-worklet/dist/geometric-paint-worklet.js"></script>
  1. Add the paint worklet module to your index.html:
<script>
    CSS.paintWorklet.addModule('node_modules/geometric-paint-worklet/dist/geometric-paint-worklet.js');
</script>
  1. Use the GeometricPaintWorklet on any Element. Ex:
.my-element {
    background-image: paint(geometricPaintWorklet);
}
  1. Customize it to your needs using custom CSS Variables (see below)

💈 3. How to customize

You can customize it using css variables. Ex:

.nice-element {
    --gpw-number-of-shapes: 32;
    --gpw-shape-size: 16;
    --gpw-line-width: 2;
    --gpw-possible-colors: ['#E57373', 'pink', 'rgb(100, 150, 34)'];
    --gpw-opacity: .25;
    
    background-image: paint(geometricPaintWorklet);
}

🦖 4. CSS Variables

| Variable | Value Type | Default | | ------------------------- |:------------- | :--------| | --gpw-number-of-shapes | number | 12 | | --gpw-shape-size | number | 40 | | --gpw-line-width | number | 40 | | --gpw-possible-colors | array | ['#FFF59D', '#FFAB91', '#80DEEA', '#E57373'] | | --gpw-fill-shapes | boolean | false | | --gpw-opacity | number | 1 |


📸 5. Examples

  1. Default Settings
.my-element {
    background-image: paint(geometricPaintWorklet);
}

Example with default settings

  1. Small shapes
.my-element {
    --gpw-number-of-shapes: 80;
    --gpw-shape-size: 6;
    --gpw-line-width: 6;
    --gpw-fill-shapes: false;
    --gpw-opacity: .5;

    background-image: paint(geometricPaintWorklet);
}

Example with small shapes

  1. Overlapping translucent forms
.my-element {
    --gpw-number-of-shapes: 24;
    --gpw-shape-size: 256;
    --gpw-line-width: 1;
    --gpw-fill-shapes: true;
    --gpw-opacity: .25;

    background-image: paint(geometricPaintWorklet);
}

Example with overlapping translucent shapes

  1. Large thin borders
.my-element {
    --gpw-number-of-shapes: 8;
    --gpw-shape-size: 240;
    --gpw-line-width: 1;
    --gpw-possible-colors: ['#ffffff'];
    
    background-image: paint(geometricPaintWorklet);
}

Example with large thin borders

  1. Solid colourful shapes
.my-element {
    --gpw-number-of-shapes: 12;
    --gpw-shape-size: 40;
    --gpw-line-width: 40;

    background-image: paint(geometricPaintWorklet);
}

Example with solid colourful shapes


😀 Have fun with it, and let me know if you use it somewhere...