roulette-gif
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

roulette-gif Logo


roulette-gif

Npm version Npm downloads Support server
This is a node.js package that allows you to make a roulette gif image as easy as possible

Installation

$ npm install roulette-gif
$ yarn add roulette-gif

Features

  • Simple & easy to use
  • You can edit everything in the wheel

Support

Join our support server for any question HL Services

Getting Started

At first you need to install the package

const { Wheel } = require('roulette-gif')
const wheel = new Wheel()

let slots = [
  {
    username: "Zaid",
    number: 1,
    image: 'Some avatar url'  // Must be png or any supported image by canvas
  },
  {
    username: "Ahmed",
    number: 2,
    image: 'Some avatar url'
  },
]

let { 
  buffer, 
  winner, 
  lastFrame 
} = await wheel.createGif({
  slots,
  stream: false, // Set it to true if you want to return stream insted of buffer
  wheelStroke: {
    color: '#fff',
    width: 5
  },
  slotStroke: {
    color: '#fff',
    width: 5
  },
  imageStroke: {
    color: '#fff',
    width: 5
  },
  winnerSlotColor: 'Gold'
})

You can use the buffer to send the roulette gif or save it and if you want to get a stream insted of buffer you can use stream: true
The lastFrame variable is a buffer of the last image in the gif
The winner variable returns the winner slot

Options

Variable Required Default Description Type
stream false false Choice to return a buffer or stream Boolean
slots true null The slots array of the users Array
wheelStroke false { width: 0, color: '#fff' } The stroke object of the wheel Object
slotStroke false { width: 0, color: '#fff' } The stroke object of the slot Object
imageStroke false { width: 0, color: '#fff' } The stroke object of the center image Object
winnerSlotColor false Slot Color Change the winner slot color Color
text false { color: '#fff', size: 14 } The text options Object
arrow false Simple arrow Use url image to change the wheel arrow URL Image

Examples

  • Send the wheel in discord
let { buffer, winner } wheel.createGif({ 
  slots
})

<Interaction | Channel>.send({ 
  files: [{ attachment: buffer, name: "roulette.png" }],
  content: `Congratulations ${winner.username} 🎉 you won`
})
  • Custom arrow
wheel.createGif({
  slots,
  arrow: 'https://example.com/arrow.png'
})
  • Custom wheel stroke
wheel.createGif({
  slots,
  wheelStroke: {
    color: 'red', // You can use hexCodes here
    width: 5
  }
})
  • Custom slot stroke
wheel.createGif({
  slots,
  slotStroke: {
    color: 'purple', // You can use hexCodes here
    width: 5
  }
})
  • Custom image stroke
wheel.createGif({
  slots,
  imageStroke: {
    color: 'green', // You can use hexCodes here
    width: 5
  }
})
  • Custom text
wheel.createGif({
  slots,
  text: {
    color: 'blue', // You can use hexCodes here
    size: 10
  }
})

Developer

Package Sidebar

Install

npm i roulette-gif

Weekly Downloads

13

Version

1.1.5

License

MIT

Unpacked Size

66.5 kB

Total Files

8

Last publish

Collaborators

  • zd8