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
Markdown
<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>