1.0.6 • Published 4 years ago

dice-textures v1.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

Dice Textures

A little module (~2kb) that generates 6 dice textures. It exposes just one functions createDiceTextures which returns an array of data URI strings.

Setup

dice-textures can be installed with npm or using a content delivery network URL to embed it on your HTML page

npm i dice-textures

or

<script src="https://unpkg.com/dice-textures/dist/dice-textures.umd.js"></script>

Usage

const diceFace5Image = document.getElementById('diceFace5Image');
const texturesOptions = { size: 300};
const outputOptions = { type: 'image/jpeg', quality: 0.5 };
const diceFaceTextures = createDiceTextures(texturesOptions, outputOptions);
diceFace5Image.src = diceFaceTextures[4];

pixi.js

import { Sprite } from 'pixi.js';
import createDiceTextures from 'dice-textures';
...
const texturesOptions = { size: 300};
const outputOptions = { type: 'image/jpeg', quality: 0.5 };
const diceFaceTextures = createDiceTextures(texturesOptions, outputOptions);
const diceFaces = diceFaceTextures.map(texture => Sprite.from(texture));

Both parameters are optional. For details see below.

Options

Textures options

NameTypeDefaultDescription
sizenumber100side of the square texture
colorstringblackany CSS color representation
strokeColorstringblackany CSS color representation
strokeLineWidthnumber0width of the stroke line
cornerRadiusnumber0rounded rect corner radius
paddingnumber0distance between the center of the pip and the dice edge
pipColorstring'white'any CSS color representation
pipStrokeColorstring'white'any CSS color representation
pipStrokeLineWidthnumber0width of the pip stroke line
pipRadiusnumber10pip radius

Output options

NameTypeDefaultDescription
typestringimage/pngimage format
qualitynumber0.92compression level

For the output options details see here

License

Copyright © 2019, Sergey Chernykh. Released under the MIT License.

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago