java刮刮卡源码_js 刮奖小程序源码(刮刮卡)

【实例简介】Lottery

一个刮奖小程序,可以在移动设备上和PC端网页(浏览器要支持canvas)上运行

【实例截图】

d59c0c5097669d90303f6e7b609d37fe.png

【核心代码】

function Lottery(id, cover, coverType, width, height, drawPercentCallback) {

this.conId = id;

this.conNode = document.getElementById(this.conId);

this.cover = cover;

this.coverType = coverType;

this.background = null;

this.backCtx = null;

this.mask = null;

this.maskCtx = null;

this.lottery = null;

this.lotteryType = 'image';

this.width = width || 300;

this.height = height || 100;

this.clientRect = null;

this.drawPercentCallback = drawPercentCallback;

}

Lottery.prototype = {

createElement: function (tagName, attributes) {

var ele = document.createElement(tagName);

for (var key in attributes) {

ele.setAttribute(key, attributes[key]);

}

return ele;

},

getTransparentPercent: function(ctx, width, height) {

var imgData = ctx.getImageData(0, 0, width, height),

pixles = imgData.data,

transPixs = [];

for (var i = 0, j = pixles.length; i < j; i = 4) {

var a =

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值