UNPKG

tiny-dices

Version:

Tiny Dices adds a sprinkle of fun and a touch of magic to your dice-rolling adventures โ€” fully customizable with CSS and JavaScript to match your style, theme, or imagination! ๐ŸŽฒโœจ

152 lines (101 loc) โ€ข 5.69 kB
<div align="center"> <p> <a href="https://discord.gg/TgHdvJd"><img src="https://img.shields.io/discord/413193536188579841?color=7289da&logo=discord&logoColor=white" alt="Discord server" /></a> <a href="https://www.npmjs.com/package/tiny-dices"><img src="https://img.shields.io/npm/v/tiny-dices.svg?maxAge=3600" alt="NPM version" /></a> <a href="https://www.npmjs.com/package/tiny-dices"><img src="https://img.shields.io/npm/dt/tiny-dices.svg?maxAge=3600" alt="NPM downloads" /></a> <a href="https://www.patreon.com/JasminDreasond"><img src="https://img.shields.io/badge/donate-patreon-F96854.svg?logo=patreon" alt="Patreon" /></a> <a href="https://ko-fi.com/jasmindreasond"><img src="https://img.shields.io/badge/donate-ko%20fi-29ABE0.svg?logo=ko-fi" alt="Ko-Fi" /></a> </p> <p> <a href="https://nodei.co/npm/tiny-dices/"><img src="https://nodei.co/npm/tiny-dices.png?downloads=true&stars=true" alt="npm installnfo" /></a> </p> </div> # ๐ŸŽฒ Tiny Dices - Fun 3D Dice Rolling with JavaScript Welcome to **Tiny Dices**! This JavaScript library is here to bring an extra layer of fun and magic to your dice-rolling experience. โœจ Whether you're rolling for your favorite tabletop RPG or just need some virtual dice to shake things up, TinyDices makes it all possible with style! ### Inspiration โœจ This project was initially a custom dice application from Pony Driland repository. The tiny dice eventually evolved during the development that resulted in this project that is now published by the same creator of the Pony Driland repository. ### Features ๐ŸŒŸ - **Roll any number of dice** โ€“ from a single die to a whole set of them! ๐ŸŽฒ - **Customizable max values** โ€“ set different max values for each die. ๐ŸŒˆ - **Spinning animation** โ€“ your dice can spin infinitely or stop after a cool animation. ๐Ÿ”„ - **Dynamic cube generation** โ€“ each die is a rotating, animated cube with unique faces. ๐ŸŽญ - **Zero-inclusive rolls** โ€“ make 0 a valid result if you need it! (Optional) ๐Ÿฅณ ### How to Use ๐ŸŒŸ 1. **Create a Dice Instance:** ```js const container = document.getElementById('myDice'); const dice = new TinyDices(container); ``` 2. **Roll Some Dice:** - ๐ŸŽฒ Roll 3 six-sided dice: ```js dice.roll('7,7,7'); // Rolls 3d7 ๐ŸŽฒ๐ŸŽฒ๐ŸŽฒ ``` - ๐ŸŽฏ Roll a mix of dice: ```js dice.roll('6,12,20'); // Rolls d6, d12, and d20 ๐Ÿ”ข๐ŸŽฒ ``` - ๐Ÿ”„ Roll with infinite spinning animation: ```js dice.roll([10, 10], false, true); // Rolls 2d10 with infinite spin ๐Ÿ”„๐ŸŽฒ ``` - ๐Ÿงฎ Roll with values starting from 0: ```js dice.roll([10, 10], true); // Rolls 2d10 starting from 0 ๐Ÿฅณ๐ŸŽฒ ``` - ๐Ÿงช Roll a custom set of dice with zero and infinity: ```js dice.roll([4, 8, 6], true, true); // Rolls d4, d8, and d6 from 0 with infinite spin โš™๏ธ๐ŸŽฒ ``` ### Customization ๐ŸŽจ Feel free to customize the appearance of your dice with different skins: - **Background Skin:** Set a cool background with solid colors like `'gray'`, `'blue'`, or `'green'`, or something magical! โœจ ```js dice.setBgSkin('gray'); // Sets background skin to gray ๐ŸŒซ๏ธ ``` - **Text Skin:** Make your dice text stand out with solid color skins like `'red'`, `'yellow'`, or `'white'`! ๐ŸŒŸ ```js dice.setTextSkin('red'); // Makes the text red ๐Ÿ”ด ``` - **Border Skin:** Add a border effect to your dice with colors like `'black'`, `'orange'`, or `'purple'`! โœจ ```js dice.setBorderSkin('2px solid black'); // Sets a black border โšซ ``` - **Get Current Skins:** Check what skins you're using right now: ```js dice.getBgSkin(); // Returns current background skin ๐ŸŽจ dice.getTextSkin(); // Returns current text skin ๐Ÿ–‹๏ธ dice.getBorderSkin(); // Returns current border skin โšก ``` --- ### ๐Ÿ’ป How It Works Tiny Dices works by creating a customizable, **3D cube** with **6 animated faces**. Every time you roll, the faces spin and reveal random numbers. ๐ŸŽฒโœจ - **The front face** shows the result of your roll ๐Ÿฅณ - **The other faces** are randomized, creating a truly unique dice experience! You can also customize the cube's animation. Want it to spin forever? Or just do a quick 360? ๐ŸŽก --- ### ๐ŸŽจ Styles & Animations Tiny Dices comes with cool animation effects and customizable styles. From **spin effects** to **face transformations**, the dice will roll in style. โœจ - **Spin it Infinite!**: Watch the dice spin forever for an endless feeling of anticipation! ๐Ÿ”„ - **Spin it Custom**: You can control how the dice rotate with custom animations. Rotate along different axes for the coolest effects! ๐Ÿ”ฎ --- ### ๐Ÿšจ Don't Forget Remember to check out the **[Tiny Dices Docs](./docs/README.md)** for more detailed instructions and advanced features! ๐Ÿ“ --- ### ๐Ÿ“ฃ Credits This project was created by **Yasmin Seidel (JasminDreasond)** with some **extra help** from **ChatGPT**. Tiny thanks to everyone contributing to the open-source community! ๐Ÿ’– --- ### License ๐Ÿ“œ This project is licensed under the GPL-3.0 License โ€“ feel free to use and customize it for your own projects! ๐Ÿ› ๏ธ --- ### ๐Ÿš€ Let's roll those tiny dice! ๐ŸŽฒ --- ## ๐Ÿ”™ Back to Tiny Essentials Did you like this module? Itโ€™s part of the **Tiny Essentials** collection โ€” a set of minimal yet powerful tools to make development easier. ๐Ÿ‘‰ [Click here to explore more Tiny Essentials modules](https://github.com/JasminDreasond/Tiny-Essentials) --- <div align="center"> <a href="./img/icons/"><img src="./img/icons/69d958d1-381f-43f9-aee5-d9ffaff3b546.png" height="300" /></a> <br/> Made with tiny love! </div>