jQuery+html5 canvas大转盘抽奖代码

来源:https://www.sucaihuo.com/js/5074.html 2020-01-15 11:29浏览(556) 收藏

基于jQuery+html5 canvas制作的大转盘抽奖代码,一款比较适合移动端的转盘抽奖代码。
jQuery+html5 canvas大转盘抽奖代码
分类:抽奖 > 转盘 难易:初级
查看演示 下载资源 下载积分: 20 积分
关注公众号,免费赠送安装视频教程、环境和学习视频,后面会不断更新。

参数设置:

var turnplate = {
    restaraunts: [], //大转盘奖品名称
    colors: [], //大转盘奖品区块对应背景颜色
    outsideRadius: 192, //大转盘外圆的半径
    textRadius: 155, //大转盘奖品位置距离圆心的距离
    insideRadius: 68, //大转盘内圆的半径
    startAngle: 0, //开始角度
    bRotate: false //false:停止;ture:旋转
};
//控制中奖结果方法
function rnd(n, m) {
    var random = 11;
    //var random = Math.floor(Math.random()*(m-n+1)+n);
    return random;
}
随机中奖结果:
rotateFn(item, turnplate.restaraunts[item - 1]);
根据停止角度指定中奖结果:
/* 
switch (item) {
    case 1:
        rotateFn(252, turnplate.restaraunts[0]);
        break;
    case 2:
        rotateFn(216, turnplate.restaraunts[1]);
        break;
    case 3:
        rotateFn(180, turnplate.restaraunts[2]);
        break;
    case 4:
        rotateFn(144, turnplate.restaraunts[3]);
        break;
    case 5:
        rotateFn(108, turnplate.restaraunts[4]);
        break;
    case 6:
        rotateFn(72, turnplate.restaraunts[5]);
        break;
    case 7:
        rotateFn(36, turnplate.restaraunts[6]);
        break;
    case 8:
        rotateFn(360, turnplate.restaraunts[7]);
        break;
    case 9:
        rotateFn(324, turnplate.restaraunts[8]);
        break;
    case 10:
        rotateFn(288, turnplate.restaraunts[9]);
        break;
}
*/
评论0
头像

系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791

1 2