Package Exports
- roulette-image
- roulette-image/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (roulette-image) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Roulette Image
This package provides functionality to create roulette images and GIFs. It utilizes the @napi-rs/canvas package for creating and manipulating images, and @skyra/gifenc for generating GIFs.
Installation
To install roulette-image, run the following command:
# NPM
npm add roulette-image
# Bun.js
bun add roulette-image
# Yarn
yarn add roulette-imageUsage
Import the required methods from the package:
import { createRouletteGifImage } from 'roulette-image';Method: createRouletteGifImage
This method generates a GIF image of a rotating roulette wheel with sectors.
async function createRouletteGifImage(sectors: any[], return_stream = false): Promise<any>sectors: An array containing the sectors of the roulette wheel.return_stream(optional): If set totrue, the method will return a readable stream of the GIF image. Default isfalse.- Returns: A Promise that resolves to the generated GIF image.
Example usage:
const sectors = [
{ number: 0, username: 'User1', color: '#FF0000', avatarURL: 'https://example.com/avatar1.png' },
{ number: 1, username: 'User2', color: '#00FF00', avatarURL: 'https://example.com/avatar2.png' },
// Add more sectors...
];
const gifBuffer = await createRouletteGifImage(sectors);
await fs.promises.writeFile("roulette.gif", gifBuffer);
console.log('File saved successfully!');- Example of an animated roulette image:
Sponsors
- Love what I do? Send me some coffee !? ☕
- Can't send coffees? Your support will help me to continue working on open-source projects like this. 🙏😇
Help
If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official Discord Server .
License
Refer to the LICENSE file.