gitmyhub

lucky-canvas

TypeScript ★ 8.7k updated 10mo ago

🎖🎖🎖 基于 TS + Canvas 开发的【大转盘 / 九宫格 / 老虎机】抽奖插件,🌈 一套源码适配多端框架 JS / Vue / React / Taro / UniApp / 微信小程序等,🎨 奖品 / 文字 / 图片 / 颜色 / 按钮均可配置,支持同步 / 异步抽奖,🎯 概率前 / 后端可控,🚀 自动根据 dpr 调整清晰度适配移动端

JavaScript plugin that adds animated prize wheels, nine-grid pickers, and slot machines to any website or mini-app, with server-controlled odds and support for Vue, React, and WeChat.

TypeScriptJavaScriptVueReactCanvas APIUniAppTarosetup: easycomplexity 2/5

Lucky-canvas is a JavaScript plugin for adding lottery and prize-drawing animations to a website or app. It provides three visual styles: a spinning prize wheel, a nine-grid scratch-card style picker, and a slot machine. All three are drawn with the Canvas API, which means they render sharply on screens of any pixel density, including high-resolution mobile displays. The README is written in Chinese; this summary is based on the description, topics, and visible structure of the project.

The plugin is designed to work across many different JavaScript environments without rewriting your code. There are separate npm packages for plain JavaScript, Vue, React, UniApp, Taro (a cross-platform mini-app framework), and WeChat Mini Programs. Each package wraps the same core drawing engine, so the behavior is consistent regardless of which framework you use.

You configure what appears in each segment of the wheel or grid by passing in a list of prizes. Each prize can be text, an image, a background color, or a button, and you can mix these freely. The plugin supports both modes of determining a winner: the result can be decided locally in the browser before the animation starts, or you can call your own backend during the spin and wait for a server response before landing on a prize. This lets you control the actual odds from a server rather than exposing probability logic to the browser.

The project is actively maintained and has English documentation listed as a work in progress. The Chinese documentation and demo site live at 100px.net. It is released under an open-source license.

Where it fits