Create beautiful, dynamic shadows using JavaScript.
"Ombro" is a noun meaning "shadow" in Esperanto.
NPM:
npm install ombro
Using it in a script tag (IIFE), where the ombro
namespace is available globally:
<script type="text/javascript" src="https://unpkg.com/ombro/dist/iife/index.js"></script>
Importing as an ES module:
<script type="module">
import { Ombro } from "https://unpkg.com/ombro/dist/esm/index.js"
...
</script>
import { Ombro, Color } from "ombro"
// Create an Ombro instance and attach it to the DOM element you'd like to shine
const element = document.getElementById("element")
const ombro = new Ombro(element, {
// Optionally set configuration options
shadowColor: new Color(0, 0, 0)
})
// Set the light position to mouse pointer coordinates
window.addEventListener("mousemove", function(event) {
ombro.setLightPosition(event.x, event.y) // set coordinates of light position
ombro.draw() // redraw shadows on change
}, false)
Preview:
See more usage examples in examples/ folder. Live demos: cursor.html, light-grid.html.
The full API documentation is available here.
Please open a new issue if you discover a bug or want to discuss a feature. If you have a bug fix ready, you are welcome to open a pull request.
Based on the unmaintained library shine.js, ported to TypeScript and added new features.
MIT Licensed.
© 2021 Tamim Arafat.
Generated using TypeDoc