0.0.2 • Published 3 years ago

houdini-tesla v0.0.2

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

houdini-tesla

houdini tesla used on a button

A CSS Houdini Worklet to paint Tesla coils.

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/houdini-tesla/dist/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/houdini-tesla/dist/worklet.js');
  })()
</script>

2. Ready to use it in your CSS!

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

.element {
  --tesla: 0; /* Entry point to animate coil and trigger repaint */
  --tesla-hue: 0;
  --tesla-saturation: 50;
  --tesla-lightness: 50;
  --tesla-blur: 10;
  --tesla-width: 10;
  --tesla-angle: 45;
  --tesla-segments: 2;
  background: paint(tesla-coil);
}
PropertyDescriptionDefault
--teslaHack, use this property to animate coil. Animating the property triggers a repaint.0
--tesla-hueHue, use this to define the hue of the coil0
--tesla-saturationSaturation, use this to define the saturation of the coil0
--tesla-lightnessLightness, use this to define the lightness of the coil0
--tesla-blurBlur, use this to define a stroke blur for the coil0
--tesla-widthWidth, use this to adjust the stroke width of the coil0
--tesla-angleAngle, use this to adjust the permitted angles in the coil0
--tesla-segmentsSegments, use this to adjust the number of segments in the coil0

Development

Run it locally!

npm i
make develop

License

MIT License

Copyright (c) 2020 jh3y