0.3.0 • Published 3 years ago

css-houdini-bullet v0.3.0

Weekly downloads
17
License
MIT
Repository
github
Last release
3 years ago

CSS Houdini Bullet

css-houdini-bullet-sample

A CSS Houdini Worklet to paint "bullet holes".

Getting started

1. Load the worklet

Using CDN is the easiest way to add the library:

if ("paintWorklet" in CSS) {
  CSS.paintWorklet.addModule(
    "https://unpkg.com/css-houdini-bullet/public/worklet.js"
  );
}

You can use the polyfill

To add support for all moder browsers, you can load the worklet with css-paint-polyfill fallback.

<script>
  (async function () {
    if (CSS["paintWorklet"] === undefined)
      await import("https://unpkg.com/css-paint-polyfill");

    CSS.paintWorklet.addModule(
      "https://unpkg.com/css-houdini-bullet/public/worklet.js"
    );
  })();
</script>

2. Ready to use it in your CSS!

To use the Bullet worklet you need to define some custom properties with values and add the value paint(bullet) on the background property.

.element {
  --bullet-bg: #3112c9, #12c99b;
  --bullet-items: 3;
  --bullet-type: 5;
  --bullet-curve: 0.5;
  --bullet-size: 10, 25;
  --bullet-border: 15;
  background: paint(tesla-coil);
}
PropertyDefaultDescription
--bullet-bg#1a2a6cDefine the background color of the element, multiple colors can be used #color1, #color2
--bullet-items10Define the number of "holes"
--bullet-type0Define the type of "hole" 0 = Circles, 1 = Hearts, n > 2 = Polygons of n points
--bullet-curve0.5Define the shorter radius of the Polygons (max value 1)
--bullet-size10Define the size of the "hole"
--bullet-border0Define the space from the border

Development

Run it locally!

yarn
yarn start

License

MIT License

Copyright (c) 2021 Edalgrin