lucky-canvas
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -16,2 +16,2 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}); | ||
***************************************************************************** */ | ||
var t=function(i,e){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=i[e])})(i,e)};function i(i,e){function n(){this.constructor=i}t(i,e),i.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var e=function(){return(e=Object.assign||function(t){for(var i,e=1,n=arguments.length;e<n;e++)for(var r in i=arguments[e])Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r]);return t}).apply(this,arguments)};function n(){for(var t=0,i=0,e=arguments.length;i<e;i++)t+=arguments[i].length;var n=Array(t),r=0;for(i=0;i<e;i++)for(var o=arguments[i],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var r=function(t){for(var i=[],e=1;e<arguments.length;e++)i[e-1]=arguments[e];return i.some((function(i){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===i}))},o=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},s=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,i=t.config,e=t.ctx,n=t.dpr,r=i.divElement,o=i.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(i.width=r.offsetWidth,i.height=r.offsetHeight,o.width=i.width*n,o.height=i.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",e.scale(n,n))},t.prototype.getLength=function(t){return r(t,"number")?t:r(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(i,e){var n=this;return void 0===e&&(e=1),Number(i.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(i,r,o){switch(o){case"%":r*=e/100;break;case"px":r*=1;break;case"rem":r*=n.htmlFontSize;break;case"rpx":r*=t.rpx2px(r);break;default:r*=1}return r})))},t.px2rpx=function(t){return wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.rpx2px=function(t){return wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var i=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(e){i.defineReactive(t,e,t[e])}))},t.prototype.defineReactive=function(t,i,e){var n=this;this.observer(e),Object.defineProperty(t,i,{get:function(){return e},set:function(t){var r=e;t!==e&&(e=t,n.observer(e),n.subs[i]&&n.subs[i].call(n,e,r),n.draw())}})},t.prototype.$set=function(t,i,e){t&&"object"==typeof t&&this.defineReactive(t,i,e)},t.prototype.$computed=function(t,i,e){var n=this;Object.defineProperty(t,i,{get:function(){return e.call(n)}})},t.prototype.$watch=function(t,i){this.subs[t]=i},t.prototype.resetArrayProto=function(){var t=this,i=Array.prototype,e=Object.create(i);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(r){e[r]=function(){var e;t.draw(),(e=i[r]).call.apply(e,n([this],Array.from(arguments)))}}))},t}(),a=function(t){return Math.PI/180*t},h=function(t,i){return[+(Math.cos(t)*i).toFixed(8),+(Math.sin(t)*i).toFixed(8)]},c=function(t,i){var e=-t/i;return[e,-e*t+i]},l=function(t,i,e,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-e).toFixed(8)>=a(180).toFixed(8)){var s=(n+e)/2;return r?(l(t,i,e,s,r),l(t,i,s,n,r)):(l(t,i,s,n,r),l(t,i,e,s,r)),!1}r||(e=(o=[n,e])[0],n=o[1]);var f=h(e,i),u=f[0],d=f[1],g=h(n,i),p=g[0],m=g[1],v=c(u,d),w=v[0],y=v[1],b=c(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+i.toFixed(8)&&(x=u),Math.abs(p)===+i.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,i)},f=function(t,i,e,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(i+o,e),t.lineTo(i+o,e),t.lineTo(i+n-o,e),t.arcTo(i+n,e,i+n,e+o,o),t.lineTo(i+n,e+r-o),t.arcTo(i+n,e+r,i+n-o,e+r,o),t.lineTo(i+o,e+r),t.arcTo(i,e+r,i,e+r-o,o),t.lineTo(i,e+o),t.arcTo(i,e,i+o,e,o),t.closePath(),t.fill()},u=function(t,i,e,n){return t>=n&&(t=n),e*(t/=n)*t+i},d=function(t,i,e,n){return t>=n&&(t=n),-e*(t/=n)*(t-2)+i},g=function(t){function s(i,e){void 0===e&&(e={});var n=t.call(this,i)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(e),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(s,t),s.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},s.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return e({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return e({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},s.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(i,e){var n=[];return e?i&&i.forEach((function(i,r){var o=[],s=e[r];s?i.imgs&&i.imgs.forEach((function(i,e){if(!s.imgs)return o[e]=i;var n=s.imgs[e];n&&t.prizeImgs[r]&&t.prizeImgs[r][e]?i.src!==n.src&&(o[e]=i):o[e]=i})):o=i.imgs||[],n[r]=o})):n=i.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(i,e){var r=[];return e?i&&i.forEach((function(i,n){var o=[],s=e[n];s&&s.imgs?i.imgs&&i.imgs.forEach((function(i,e){if(!s.imgs)return o[e]=i;var r=s.imgs[e];r&&t.btnImgs[n]&&t.btnImgs[n][e]?i.src!==r.src&&(o[e]=i):o[e]=i})):o=i.imgs||[],r[n]=o})):r=i.map((function(t){return t.imgs})),t.init(n(new Array(t.prizes.length).fill(void 0),r))}))},s.prototype.init=function(t){var i=this,e=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(e.width,e.height)/2,n.translate(this.Radius,this.Radius);var o=function(){i.draw(),e.canvasElement&&(e.canvasElement.onclick=function(t){var e;n.beginPath(),n.arc(0,0,i.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(i.startTime||null===(e=i.startCallback)||void 0===e||e.call(i,t))})},s=0,a=0;r(t,"array")&&(this.draw(),t.forEach((function(t,e){if(!t)return!1;t.forEach((function(t,n){a++,i.loadAndCacheImg(e,n,(function(){s++,a===s&&o.call(i)}))}))}))),a||o.call(this)},s.prototype.loadAndCacheImg=function(t,i,e){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[i];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][i]=c,c.src=h.src,c.onload=function(){return e.call(n)}}}},s.prototype.computedWidthAndHeight=function(t,i,e,n){if(!i.width&&!i.height)return[t.width,t.height];if(i.width&&!i.height){var r=this.getWidth(i.width,e);return[r,t.height*(r/t.width)]}if(!i.width&&i.height){var o=this.getHeight(i.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(i.width,e),this.getHeight(i.height,n)]},s.prototype.draw=function(){var t=this,i=this,e=i.ctx,n=i._defaultConfig,r=i._defaultStyle;e.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(i,n){return e.beginPath(),e.fillStyle=n.background,e.arc(0,0,i,0,2*Math.PI,!1),e.fill(),i-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=a(this.prizeDeg);var s=a(-90+this.rotateDeg+n.offsetDegree),c=function(i){return t.getOffsetX(e.measureText(i).width)},f=function(i,e,n){var o=i.lineHeight||r.lineHeight||i.fontSize||r.fontSize;return t.getHeight(i.top,e)+(n+1)*t.getLength(o)};e.save(),this.prizes.forEach((function(i,u){var d=s+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,i,e,n,r,o,s){i||(i=o);var c=a(90/Math.PI/e*o),f=a(90/Math.PI/i*o),u=n+c,d=r-c,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,h(u,e)),l(t,e,u,d,!0),p>g?l(t,i,g,p,!1):t.lineTo.apply(t,h((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(e,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),i.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;e.translate(p,m),e.rotate(d+a(90)),i.imgs&&i.imgs.forEach((function(i,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,i,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];e.drawImage(r,t.getOffsetX(s),t.getHeight(i.top,g),s,a)}}})),i.fonts&&i.fonts.forEach((function(i){var s=i.fontColor||r.fontColor,a=i.fontWeight||r.fontWeight,h=t.getLength(i.fontSize||r.fontSize),l=i.fontStyle||r.fontStyle;e.fillStyle=s,e.font=a+" "+h+"px "+l;var u=[],d=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:r.wordWrap){d=o(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=e.measureText(p).width,w=(t.prizeRadius-f(i,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(i.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){e.fillText(t,c(t),f(i,g,n))}))})),e.rotate(a(360)-d-a(90)),e.translate(-p,-m)})),e.restore(),this.buttons.forEach((function(i,n){var o=t.getHeight(i.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),e.beginPath(),e.fillStyle=i.background||"rgba(0, 0, 0, 0)",e.arc(0,0,o,0,2*Math.PI,!1),e.fill(),i.pointer&&(e.beginPath(),e.fillStyle=i.background||"rgba(0, 0, 0, 0)",e.moveTo(-o,0),e.lineTo(o,0),e.lineTo(0,2*-o),e.closePath(),e.fill()),i.imgs&&i.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(i.radius),2*t.getHeight(i.radius)),c=h[0],l=h[1];e.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,l)}}})),i.fonts&&i.fonts.forEach((function(i){var n=i.fontColor||r.fontColor,s=i.fontWeight||r.fontWeight,a=t.getLength(i.fontSize||r.fontSize),h=i.fontStyle||r.fontStyle;e.fillStyle=n,e.font=s+" "+a+"px "+h,String(i.text).split("\n").forEach((function(t,n){e.fillText(t,c(t),f(i,o,n))}))}))}))},s.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},s.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},s.prototype.run=function(t){void 0===t&&(t=0);var i=this,e=i.rAF,n=i.cAF,r=i.prizeFlag,o=i.prizeDeg,s=i.rotateDeg,a=i._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var l=360*c-r*o-s-a.offsetDegree;if(d(this.FPS,this.stopDeg,l,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=l;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+u(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=e(this.run.bind(this,t+1))},s.prototype.slowDown=function(){var t,i=this,n=i.rAF,r=i.cAF,o=i.prizes,s=i.prizeFlag,a=i.stopDeg,h=i.endDeg,c=i._defaultConfig,l=Date.now()-this.endTime;if(l>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,e({},o.find((function(t,i){return i===s})))),r(this.animationId);this.rotateDeg=d(l,a,h,c.decelerationTime)%360,this.draw(),this.animationId=n(this.slowDown.bind(this))},s.prototype.getWidth=function(t,i){return void 0===i&&(i=this.prizeRadian*this.prizeRadius),r(t,"number")?t:r(t,"string")?this.changeUnits(t,i):0},s.prototype.getHeight=function(t,i){return void 0===i&&(i=this.prizeRadius),r(t,"number")?t:r(t,"string")?this.changeUnits(t,i):0},s.prototype.getOffsetX=function(t){return-t/2},s}(s),p=function(t){function s(i,e){void 0===e&&(e={});var n=t.call(this,i)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(e),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(s,t),s.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},s.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var i=e({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return i.gutter=t.getLength(i.gutter),i.speed=i.speed/40,i})),this.$computed(this,"_defaultStyle",(function(){return e({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return e({background:"#ffce98",shadow:""},t.activeStyle)}))},s.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(i,e){var n=[];return e?i&&i.forEach((function(i,r){var o=[],s=e[r];s?i.imgs&&i.imgs.forEach((function(i,e){if(!s.imgs)return o[e]=i;var n=s.imgs[e];n&&t.cellImgs[r][e]?i.src!==n.src&&(o[e]=i):o[e]=i})):o=i.imgs||[],n[r]=o})):n=i.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(i,e){var n=[],r=t.cols*t.rows-1;if(e&&e.imgs){if(i.imgs){var o=[];i.imgs.forEach((function(i,n){if(!e.imgs)return o[n]=i;var s=e.imgs[n];s&&t.cellImgs[r][n]?i.src!==s.src&&(o[n]=i):o[n]=i})),n[r]=o}}else n[r]=i.imgs;return t.init(n)}))},s.prototype.init=function(t){var i=this,e=this,n=e.config,o=e.ctx,s=e.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){i.draw(),i.demo&&i.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var e,n=i.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),r=n[0],a=n[1],h=n[2],c=n[3];o.beginPath(),o.rect(r,a,h,c),o.isPointInPath(t.offsetX,t.offsetY)&&(i.startTime||null===(e=i.startCallback)||void 0===e||e.call(i,t))})},h=0,c=0;r(t,"array")&&(this.draw(),t.forEach((function(t,e){if(!t)return!1;t.forEach((function(t,n){c++,i.loadAndCacheImg(e,n,(function(){h++,c===h&&a.call(i)}))}))}))),c||a.call(this)},s.prototype.loadAndCacheImg=function(t,i,e){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[i];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][i]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&e.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][i].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&e.call(n)}}}},s.prototype.computedWidthAndHeight=function(t,i,e){if(!i.width&&!i.height)return[t.width,t.height];if(i.width&&!i.height){var n=this.getWidth(i.width,e.col);return[n,t.height*(n/t.width)]}if(!i.width&&i.height){var r=this.getHeight(i.height,e.row);return[t.width*(r/t.height),r]}return[this.getWidth(i.width,e.col),this.getHeight(i.height,e.row)]},s.prototype.draw=function(){var t=this,i=this,e=i.config,s=i.ctx,a=i._defaultConfig,h=i._defaultStyle,c=i._activeStyle;s.clearRect(0,0,e.width,e.height),this.cells=n(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(i,e){var n=i.x,o=i.y,a=i.w,h=i.h,c=function(t){var i=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],e=0,n=0,o=0,s=0;switch(i.length){case 1:e=n=o=s=i[0];break;case 2:e=n=i[0],o=s=i[1];break;case 3:e=i[0],o=s=i[1],n=i[2];break;default:e=i[0],n=i[1],o=i[2],s=i[3]}var a={paddingTop:e,paddingBottom:n,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&r(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[e,n,o,s]}(e).map((function(t){return~~t})),l=c[0],u=c[1],d=c[2],g=c[3],p=e.borderRadius?t.getLength(e.borderRadius):0;return f(s,n,o,a,h,p,t.handleBackground(n,o,a,h,e.background)),{x:n+d,y:o+l,w:a-d-g,h:h-l-u}}),{x:0,y:0,w:e.width,h:e.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(i,e){var n=t.getGeometricProperty([i.x,i.y,i.col,i.row]),r=n[0],a=n[1],l=n[2],u=n[3],d=e===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:i.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,i){return i<3?Number(t):t}));4===g.length&&(s.shadowColor=g[3],s.shadowOffsetX=g[0],s.shadowOffsetY=g[1],s.shadowBlur=g[2],g[0]>0?l-=g[0]:(l+=g[0],r-=g[0]),g[1]>0?u-=g[1]:(u+=g[1],a-=g[1])),f(s,r,a,l,u,t.getLength(i.borderRadius?i.borderRadius:h.borderRadius),t.handleBackground(r,a,l,u,i.background,d)),s.shadowColor="rgba(255, 255, 255, 0)",s.shadowOffsetX=0,s.shadowOffsetY=0,s.shadowBlur=0,i.imgs&&i.imgs.forEach((function(n,o){if(!t.cellImgs[e])return!1;var h=t.cellImgs[e][o];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,l=t.computedWidthAndHeight(c,n,i),f=l[0],u=l[1];s.drawImage(c,r+t.getOffsetX(f,i.col),a+t.getHeight(n.top,i.row),f,u)})),i.fonts&&i.fonts.forEach((function(e){var n=d&&c.fontStyle?c.fontStyle:e.fontStyle||h.fontStyle,l=d&&c.fontWeight?c.fontWeight:e.fontWeight||h.fontWeight,f=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(e.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:e.lineHeight||h.lineHeight||e.fontSize||h.fontSize;s.font=l+" "+f+"px "+n,s.fillStyle=d&&c.fontColor?c.fontColor:e.fontColor||h.fontColor;var g=[],p=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:h.wordWrap){p=o(p);for(var m="",v=0;v<p.length;v++){m+=p[v],s.measureText(m).width>t.getWidth(e.lengthLimit||h.lengthLimit,i.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(n,o){s.fillText(n,r+t.getOffsetX(s.measureText(n).width,i.col),a+t.getHeight(e.top,i.row)+(o+1)*t.getLength(u))}))}))}))},s.prototype.handleBackground=function(t,i,e,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,i,e,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[i,e+r,i+n,e+r-n*c(a-0)]:a>=45&&a<90?h=[i,e+r,i+n-r*c(a-45),e]:a>=90&&a<135?h=[i+n,e+r,i+n-r*c(a-90),e]:a>=135&&a<180?h=[i+n,e+r,i,e+n*c(a-135)]:a>=180&&a<225?h=[i+n,e,i,e+n*c(a-180)]:a>=225&&a<270?h=[i+n,e,i+r*c(a-225),e+r]:a>=270&&a<315?h=[i,e,i+r*c(a-270),e+r]:a>=315&&a<360&&(h=[i,e,i+n,e+r-n*c(a-315)])}else a.includes("top")?h=[i,e+r,i,e]:a.includes("bottom")?h=[i,e,i,e+r]:a.includes("left")?h=[i+n,e,i,e]:a.includes("right")&&(h=[i,e,i+n,e]);var l=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,i,e){var n=i.split(" ");return 1===n.length?t.addColorStop(e,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),l)}(a,t,i,e,n,r)),r},s.prototype.play=function(){var t=this.cAF,i=this.clearInterval;this.startTime||(i(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},s.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},s.prototype.run=function(t){void 0===t&&(t=0);var i=this,e=i.rAF,n=i.cAF,r=i.currIndex,o=i.prizes,s=i.prizeFlag,a=i.startTime,h=i._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var l=0;++l;){var f=o.length*l+s-(r>>0);if(d(this.FPS,this.stopIndex,f,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=f;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+u(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=e(this.run.bind(this,t+1))},s.prototype.slowDown=function(){var t,i=this,n=i.rAF,r=i.cAF,o=i.prizes,s=i.prizeFlag,a=i.stopIndex,h=i.endIndex,c=i._defaultConfig,l=Date.now()-this.endTime;if(l>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,e({},o.find((function(t,i){return i===s})))),r(this.animationId);this.currIndex=d(l,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=n(this.slowDown.bind(this))},s.prototype.walk=function(){var t=this,i=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=i((function(){t.currIndex+=1,t.draw()}),1300)},s.prototype.getGeometricProperty=function(t){var i=t[0],e=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*i,this.prizeArea.y+(s+a)*e];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},s.prototype.getWidth=function(t,i){return void 0===i&&(i=1),r(t,"number")?t:r(t,"string")?this.changeUnits(t,this.cellWidth*i+this._defaultConfig.gutter*(i-1)):0},s.prototype.getHeight=function(t,i){return void 0===i&&(i=1),r(t,"number")?t:r(t,"string")?this.changeUnits(t,this.cellHeight*i+this._defaultConfig.gutter*(i-1)):0},s.prototype.getOffsetX=function(t,i){return void 0===i&&(i=1),(this.cellWidth*i+this._defaultConfig.gutter*(i-1)-t)/2},s}(s);exports.LuckyGrid=p,exports.LuckyWheel=g; | ||
var t=function(e,i){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(e,i)};function e(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var i=function(){return(i=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function n(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var r=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},o=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},s=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.divElement,o=e.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(e.width=r.offsetWidth,e.height=r.offsetHeight,o.width=e.width*n,o.height=e.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",i.scale(n,n))},t.prototype.getLength=function(t){return r(t,"number")?t:r(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(r){i[r]=function(){var i;t.draw(),(i=e[r]).call.apply(i,n([this],Array.from(arguments)))}}))},t}(),a=function(t){return Math.PI/180*t},h=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},c=function(t,e){var i=-t/e;return[i,-i*t+e]},l=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=a(180).toFixed(8)){var s=(n+i)/2;return r?(l(t,e,i,s,r),l(t,e,s,n,r)):(l(t,e,s,n,r),l(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var f=h(i,e),u=f[0],d=f[1],g=h(n,e),p=g[0],m=g[1],v=c(u,d),w=v[0],y=v[1],b=c(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+e.toFixed(8)&&(x=u),Math.abs(p)===+e.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,e)},f=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.arcTo(e+n,i,e+n,i+o,o),t.lineTo(e+n,i+r-o),t.arcTo(e+n,i+r,e+n-o,i+r,o),t.lineTo(e+o,i+r),t.arcTo(e,i+r,e,i+r-o,o),t.lineTo(e,i+o),t.arcTo(e,i,e+o,i,o),t.closePath(),t.fill()},u=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},d=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},g=function(t){function s(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return e(s,t),s.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},s.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return i({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return i({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},s.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var r=[];return i?e&&e.forEach((function(e,n){var o=[],s=i[n];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var r=s.imgs[i];r&&t.btnImgs[n]&&t.btnImgs[n][i]?e.src!==r.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],r[n]=o})):r=e.map((function(t){return t.imgs})),t.init(n(new Array(t.prizes.length).fill(void 0),r))}))},s.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,n.translate(this.Radius,this.Radius);var o=function(){e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},s=0,a=0;r(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){s++,a===s&&o.call(e)}))}))}))),a||o.call(this)},s.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[e];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][e]=c,c.src=h.src,c.onload=function(){return i.call(n)}}}},s.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},s.prototype.draw=function(){var t=this,e=this,i=e.ctx,n=e._defaultConfig,r=e._defaultStyle;i.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,n){return i.beginPath(),i.fillStyle=n.background,i.arc(0,0,e,0,2*Math.PI,!1),i.fill(),e-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=a(this.prizeDeg);var s=a(-90+this.rotateDeg+n.offsetDegree),c=function(e){return t.getOffsetX(i.measureText(e).width)},f=function(e,i,n){var o=e.lineHeight||r.lineHeight||e.fontSize||r.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(o)};i.save(),this.prizes.forEach((function(e,u){var d=s+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){e||(e=o);var c=a(90/Math.PI/i*o),f=a(90/Math.PI/e*o),u=n+c,d=r-c,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,h(u,i)),l(t,i,u,d,!0),p>g?l(t,e,g,p,!1):t.lineTo.apply(t,h((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(i,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),e.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;i.translate(p,m),i.rotate(d+a(90)),e.imgs&&e.imgs.forEach((function(e,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,e,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];i.drawImage(r,t.getOffsetX(s),t.getHeight(e.top,g),s,a)}}})),e.fonts&&e.fonts.forEach((function(e){var s=e.fontColor||r.fontColor,a=e.fontWeight||r.fontWeight,h=t.getLength(e.fontSize||r.fontSize),l=e.fontStyle||r.fontStyle;i.fillStyle=s,i.font=a+" "+h+"px "+l;var u=[],d=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:r.wordWrap){d=o(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=i.measureText(p).width,w=(t.prizeRadius-f(e,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(e.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){i.fillText(t,c(t),f(e,g,n))}))})),i.rotate(a(360)-d-a(90)),i.translate(-p,-m)})),i.restore(),this.buttons.forEach((function(e,n){var o=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.arc(0,0,o,0,2*Math.PI,!1),i.fill(),e.pointer&&(i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.moveTo(-o,0),i.lineTo(o,0),i.lineTo(0,2*-o),i.closePath(),i.fill()),e.imgs&&e.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=h[0],l=h[1];i.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,l)}}})),e.fonts&&e.fonts.forEach((function(e){var n=e.fontColor||r.fontColor,s=e.fontWeight||r.fontWeight,a=t.getLength(e.fontSize||r.fontSize),h=e.fontStyle||r.fontStyle;i.fillStyle=n,i.font=s+" "+a+"px "+h,String(e.text).split("\n").forEach((function(t,n){i.fillText(t,c(t),f(e,o,n))}))}))}))},s.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},s.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},s.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.prizeFlag,o=e.prizeDeg,s=e.rotateDeg,a=e._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var l=360*c-r*o-s-a.offsetDegree;if(d(this.FPS,this.stopDeg,l,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=l;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+u(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=i(this.run.bind(this,t+1))},s.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopDeg,h=e.endDeg,c=e._defaultConfig,l=Date.now()-this.endTime;if(l>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,i({},o.find((function(t,e){return e===s})))),r(this.animationId);this.rotateDeg=d(l,a,h,c.decelerationTime)%360,this.draw(),this.animationId=n(this.slowDown.bind(this))},s.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),r(t,"number")?t:r(t,"string")?this.changeUnits(t,e):0},s.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),r(t,"number")?t:r(t,"string")?this.changeUnits(t,e):0},s.prototype.getOffsetX=function(t){return-t/2},s}(s),p=function(t){function s(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return e(s,t),s.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},s.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=i({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return i({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return i({background:"#ffce98",shadow:""},t.activeStyle)}))},s.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},s.prototype.init=function(t){var e=this,i=this,n=i.config,o=i.ctx,s=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),r=n[0],a=n[1],h=n[2],c=n[3];o.beginPath(),o.rect(r,a,h,c),o.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;r(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},s.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[e];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][e]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&i.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][e].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&i.call(n)}}}},s.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},s.prototype.draw=function(){var t=this,e=this,i=e.config,s=e.ctx,a=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;s.clearRect(0,0,i.width,i.height),this.cells=n(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var n=e.x,o=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,o=0,s=0;switch(e.length){case 1:i=n=o=s=e[0];break;case 2:i=n=e[0],o=s=e[1];break;case 3:i=e[0],o=s=e[1],n=e[2];break;default:i=e[0],n=e[1],o=e[2],s=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:o,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&r(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,o,s]}(i).map((function(t){return~~t})),l=c[0],u=c[1],d=c[2],g=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return f(s,n,o,a,h,p,t.handleBackground(n,o,a,h,i.background)),{x:n+d,y:o+l,w:a-d-g,h:h-l-u}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var n=t.getGeometricProperty([e.x,e.y,e.col,e.row]),r=n[0],a=n[1],l=n[2],u=n[3],d=i===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===g.length&&(s.shadowColor=g[3],s.shadowOffsetX=g[0],s.shadowOffsetY=g[1],s.shadowBlur=g[2],g[0]>0?l-=g[0]:(l+=g[0],r-=g[0]),g[1]>0?u-=g[1]:(u+=g[1],a-=g[1])),f(s,r,a,l,u,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(r,a,l,u,e.background,d)),s.shadowColor="rgba(255, 255, 255, 0)",s.shadowOffsetX=0,s.shadowOffsetY=0,s.shadowBlur=0,e.imgs&&e.imgs.forEach((function(n,o){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][o];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,l=t.computedWidthAndHeight(c,n,e),f=l[0],u=l[1];s.drawImage(c,r+t.getOffsetX(f,e.col),a+t.getHeight(n.top,e.row),f,u)})),e.fonts&&e.fonts.forEach((function(i){var n=d&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,l=d&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,f=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;s.font=l+" "+f+"px "+n,s.fillStyle=d&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=o(p);for(var m="",v=0;v<p.length;v++){m+=p[v],s.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(n,o){s.fillText(n,r+t.getOffsetX(s.measureText(n).width,e.col),a+t.getHeight(i.top,e.row)+(o+1)*t.getLength(u))}))}))}))},s.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var l=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),l)}(a,t,e,i,n,r)),r},s.prototype.play=function(){var t=this.cAF,e=this.clearInterval;this.startTime||(e(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},s.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},s.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.currIndex,o=e.prizes,s=e.prizeFlag,a=e.startTime,h=e._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var l=0;++l;){var f=o.length*l+s-(r>>0);if(d(this.FPS,this.stopIndex,f,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=f;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+u(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=i(this.run.bind(this,t+1))},s.prototype.slowDown=function(){var t,e=this,n=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopIndex,h=e.endIndex,c=e._defaultConfig,l=Date.now()-this.endTime;if(l>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,i({},o.find((function(t,e){return e===s})))),r(this.animationId);this.currIndex=d(l,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=n(this.slowDown.bind(this))},s.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},s.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},s.prototype.getWidth=function(t,e){return void 0===e&&(e=1),r(t,"number")?t:r(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},s.prototype.getHeight=function(t,e){return void 0===e&&(e=1),r(t,"number")?t:r(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},s.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},s}(s);exports.LuckyGrid=p,exports.LuckyWheel=g; |
@@ -15,2 +15,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LuckyCanvas={})}(this,(function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var o=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},a=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.divElement,o=e.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(e.width=r.offsetWidth,e.height=r.offsetHeight,o.width=e.width*n,o.height=e.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",i.scale(n,n))},t.prototype.getLength=function(t){return o(t,"number")?t:o(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(e,i){var n=this;return void 0===i&&(i=1),Number(e.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(e,r,o){switch(o){case"%":r*=i/100;break;case"px":r*=1;break;case"rem":r*=n.htmlFontSize;break;case"rpx":r*=t.rpx2px(r);break;default:r*=1}return r})))},t.px2rpx=function(t){return wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.rpx2px=function(t){return wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,r([this],Array.from(arguments)))}}))},t}(),h=function(t){return Math.PI/180*t},c=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},l=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=h(180).toFixed(8)){var s=(n+i)/2;return r?(l(t,e,i,s,r),l(t,e,s,n,r)):(l(t,e,s,n,r),l(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=c(i,e),u=a[0],d=a[1],g=c(n,e),p=g[0],m=g[1],v=f(u,d),w=v[0],y=v[1],b=f(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+e.toFixed(8)&&(x=u),Math.abs(p)===+e.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,e)},u=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.arcTo(e+n,i,e+n,i+o,o),t.lineTo(e+n,i+r-o),t.arcTo(e+n,i+r,e+n-o,i+r,o),t.lineTo(e+o,i+r),t.arcTo(e,i+r,e,i+r-o,o),t.lineTo(e,i+o),t.arcTo(e,i,e+o,i,o),t.closePath(),t.fill()},d=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},g=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},p=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(r(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,n.translate(this.Radius,this.Radius);var r=function(){e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},s=0,a=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){s++,a===s&&r.call(e)}))}))}))),a||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[e];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][e]=c,c.src=h.src,c.onload=function(){return i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.ctx,n=e._defaultConfig,r=e._defaultStyle;i.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,n){return i.beginPath(),i.fillStyle=n.background,i.arc(0,0,e,0,2*Math.PI,!1),i.fill(),e-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=h(this.prizeDeg);var o=h(-90+this.rotateDeg+n.offsetDegree),a=function(e){return t.getOffsetX(i.measureText(e).width)},f=function(e,i,n){var o=e.lineHeight||r.lineHeight||e.fontSize||r.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(o)};i.save(),this.prizes.forEach((function(e,u){var d=o+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){e||(e=o);var a=h(90/Math.PI/i*o),f=h(90/Math.PI/e*o),u=n+a,d=r-a,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,c(u,i)),l(t,i,u,d,!0),p>g?l(t,e,g,p,!1):t.lineTo.apply(t,c((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(i,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),e.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;i.translate(p,m),i.rotate(d+h(90)),e.imgs&&e.imgs.forEach((function(e,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,e,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];i.drawImage(r,t.getOffsetX(s),t.getHeight(e.top,g),s,a)}}})),e.fonts&&e.fonts.forEach((function(e){var o=e.fontColor||r.fontColor,h=e.fontWeight||r.fontWeight,c=t.getLength(e.fontSize||r.fontSize),l=e.fontStyle||r.fontStyle;i.fillStyle=o,i.font=h+" "+c+"px "+l;var u=[],d=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:r.wordWrap){d=s(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=i.measureText(p).width,w=(t.prizeRadius-f(e,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(e.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){i.fillText(t,a(t),f(e,g,n))}))})),i.rotate(h(360)-d-h(90)),i.translate(-p,-m)})),i.restore(),this.buttons.forEach((function(e,n){var o=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.arc(0,0,o,0,2*Math.PI,!1),i.fill(),e.pointer&&(i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.moveTo(-o,0),i.lineTo(o,0),i.lineTo(0,2*-o),i.closePath(),i.fill()),e.imgs&&e.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=h[0],f=h[1];i.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var n=e.fontColor||r.fontColor,s=e.fontWeight||r.fontWeight,h=t.getLength(e.fontSize||r.fontSize),c=e.fontStyle||r.fontStyle;i.fillStyle=n,i.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,n){i.fillText(t,a(t),f(e,o,n))}))}))}))},e.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.prizeFlag,o=e.prizeDeg,s=e.rotateDeg,a=e._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var f=360*c-r*o-s-a.offsetDegree;if(g(this.FPS,this.stopDeg,f,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=f;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+d(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopDeg,h=e.endDeg,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.rotateDeg=g(f,a,h,c.decelerationTime)%360,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(a),m=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,s=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),o=n[0],a=n[1],h=n[2],c=n[3];r.beginPath(),r.rect(o,a,h,c),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[e];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][e]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&i.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][e].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,a=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=r(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,s=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,s=0;switch(e.length){case 1:i=n=r=s=e[0];break;case 2:i=n=e[0],r=s=e[1];break;case 3:i=e[0],r=s=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],s=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&o(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,s]}(i).map((function(t){return~~t})),f=c[0],l=c[1],d=c[2],g=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return u(n,r,s,a,h,p,t.handleBackground(r,s,a,h,i.background)),{x:r+d,y:s+f,w:a-d-g,h:h-f-l}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],a=r[1],f=r[2],l=r[3],d=i===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===g.length&&(n.shadowColor=g[3],n.shadowOffsetX=g[0],n.shadowOffsetY=g[1],n.shadowBlur=g[2],g[0]>0?f-=g[0]:(f+=g[0],o-=g[0]),g[1]>0?l-=g[1]:(l+=g[1],a-=g[1])),u(n,o,a,f,l,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,a,f,l,e.background,d)),n.shadowColor="rgba(255, 255, 255, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,s){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][s];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),l=f[0],u=f[1];n.drawImage(c,o+t.getOffsetX(l,e.col),a+t.getHeight(r.top,e.row),l,u)})),e.fonts&&e.fonts.forEach((function(i){var r=d&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,f=d&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,l=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=f+" "+l+"px "+r,n.fillStyle=d&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=s(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,s){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(s+1)*t.getLength(u))}))}))}))},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var f=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),f)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.cAF,e=this.clearInterval;this.startTime||(e(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.currIndex,o=e.prizes,s=e.prizeFlag,a=e.startTime,h=e._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var f=0;++f;){var l=o.length*f+s-(r>>0);if(g(this.FPS,this.stopIndex,l,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=l;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+d(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopIndex,h=e.endIndex,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.currIndex=g(f,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(a);t.LuckyGrid=m,t.LuckyWheel=p,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var o=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},a=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.divElement,o=e.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(e.width=r.offsetWidth,e.height=r.offsetHeight,o.width=e.width*n,o.height=e.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",i.scale(n,n))},t.prototype.getLength=function(t){return o(t,"number")?t:o(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,r([this],Array.from(arguments)))}}))},t}(),h=function(t){return Math.PI/180*t},c=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},l=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=h(180).toFixed(8)){var s=(n+i)/2;return r?(l(t,e,i,s,r),l(t,e,s,n,r)):(l(t,e,s,n,r),l(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=c(i,e),u=a[0],d=a[1],g=c(n,e),p=g[0],m=g[1],v=f(u,d),w=v[0],y=v[1],b=f(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+e.toFixed(8)&&(x=u),Math.abs(p)===+e.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,e)},u=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.arcTo(e+n,i,e+n,i+o,o),t.lineTo(e+n,i+r-o),t.arcTo(e+n,i+r,e+n-o,i+r,o),t.lineTo(e+o,i+r),t.arcTo(e,i+r,e,i+r-o,o),t.lineTo(e,i+o),t.arcTo(e,i,e+o,i,o),t.closePath(),t.fill()},d=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},g=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},p=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(r(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,n.translate(this.Radius,this.Radius);var r=function(){e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},s=0,a=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){s++,a===s&&r.call(e)}))}))}))),a||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[e];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][e]=c,c.src=h.src,c.onload=function(){return i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.ctx,n=e._defaultConfig,r=e._defaultStyle;i.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,n){return i.beginPath(),i.fillStyle=n.background,i.arc(0,0,e,0,2*Math.PI,!1),i.fill(),e-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=h(this.prizeDeg);var o=h(-90+this.rotateDeg+n.offsetDegree),a=function(e){return t.getOffsetX(i.measureText(e).width)},f=function(e,i,n){var o=e.lineHeight||r.lineHeight||e.fontSize||r.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(o)};i.save(),this.prizes.forEach((function(e,u){var d=o+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){e||(e=o);var a=h(90/Math.PI/i*o),f=h(90/Math.PI/e*o),u=n+a,d=r-a,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,c(u,i)),l(t,i,u,d,!0),p>g?l(t,e,g,p,!1):t.lineTo.apply(t,c((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(i,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),e.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;i.translate(p,m),i.rotate(d+h(90)),e.imgs&&e.imgs.forEach((function(e,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,e,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];i.drawImage(r,t.getOffsetX(s),t.getHeight(e.top,g),s,a)}}})),e.fonts&&e.fonts.forEach((function(e){var o=e.fontColor||r.fontColor,h=e.fontWeight||r.fontWeight,c=t.getLength(e.fontSize||r.fontSize),l=e.fontStyle||r.fontStyle;i.fillStyle=o,i.font=h+" "+c+"px "+l;var u=[],d=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:r.wordWrap){d=s(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=i.measureText(p).width,w=(t.prizeRadius-f(e,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(e.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){i.fillText(t,a(t),f(e,g,n))}))})),i.rotate(h(360)-d-h(90)),i.translate(-p,-m)})),i.restore(),this.buttons.forEach((function(e,n){var o=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.arc(0,0,o,0,2*Math.PI,!1),i.fill(),e.pointer&&(i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.moveTo(-o,0),i.lineTo(o,0),i.lineTo(0,2*-o),i.closePath(),i.fill()),e.imgs&&e.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=h[0],f=h[1];i.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var n=e.fontColor||r.fontColor,s=e.fontWeight||r.fontWeight,h=t.getLength(e.fontSize||r.fontSize),c=e.fontStyle||r.fontStyle;i.fillStyle=n,i.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,n){i.fillText(t,a(t),f(e,o,n))}))}))}))},e.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.prizeFlag,o=e.prizeDeg,s=e.rotateDeg,a=e._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var f=360*c-r*o-s-a.offsetDegree;if(g(this.FPS,this.stopDeg,f,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=f;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+d(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopDeg,h=e.endDeg,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.rotateDeg=g(f,a,h,c.decelerationTime)%360,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(a),m=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,s=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),o=n[0],a=n[1],h=n[2],c=n[3];r.beginPath(),r.rect(o,a,h,c),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[e];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][e]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&i.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][e].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,a=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=r(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,s=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,s=0;switch(e.length){case 1:i=n=r=s=e[0];break;case 2:i=n=e[0],r=s=e[1];break;case 3:i=e[0],r=s=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],s=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&o(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,s]}(i).map((function(t){return~~t})),f=c[0],l=c[1],d=c[2],g=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return u(n,r,s,a,h,p,t.handleBackground(r,s,a,h,i.background)),{x:r+d,y:s+f,w:a-d-g,h:h-f-l}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],a=r[1],f=r[2],l=r[3],d=i===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===g.length&&(n.shadowColor=g[3],n.shadowOffsetX=g[0],n.shadowOffsetY=g[1],n.shadowBlur=g[2],g[0]>0?f-=g[0]:(f+=g[0],o-=g[0]),g[1]>0?l-=g[1]:(l+=g[1],a-=g[1])),u(n,o,a,f,l,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,a,f,l,e.background,d)),n.shadowColor="rgba(255, 255, 255, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,s){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][s];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),l=f[0],u=f[1];n.drawImage(c,o+t.getOffsetX(l,e.col),a+t.getHeight(r.top,e.row),l,u)})),e.fonts&&e.fonts.forEach((function(i){var r=d&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,f=d&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,l=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=f+" "+l+"px "+r,n.fillStyle=d&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=s(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,s){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(s+1)*t.getLength(u))}))}))}))},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var f=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),f)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.cAF,e=this.clearInterval;this.startTime||(e(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.currIndex,o=e.prizes,s=e.prizeFlag,a=e.startTime,h=e._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var f=0;++f;){var l=o.length*f+s-(r>>0);if(g(this.FPS,this.stopIndex,l,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=l;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+d(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopIndex,h=e.endIndex,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.currIndex=g(f,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(a);t.LuckyGrid=m,t.LuckyWheel=p,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "lucky-canvas", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "一个基于原生 js 的(大转盘抽奖 / 九宫格抽奖)插件", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,2 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).LuckyCanvas={})}(this,(function(t){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var o=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},a=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.divElement,o=e.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(e.width=r.offsetWidth,e.height=r.offsetHeight,o.width=e.width*n,o.height=e.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",i.scale(n,n))},t.prototype.getLength=function(t){return o(t,"number")?t:o(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(e,i){var n=this;return void 0===i&&(i=1),Number(e.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(e,r,o){switch(o){case"%":r*=i/100;break;case"px":r*=1;break;case"rem":r*=n.htmlFontSize;break;case"rpx":r*=t.rpx2px(r);break;default:r*=1}return r})))},t.px2rpx=function(t){return wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.rpx2px=function(t){return wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,r([this],Array.from(arguments)))}}))},t}(),h=function(t){return Math.PI/180*t},c=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},l=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=h(180).toFixed(8)){var s=(n+i)/2;return r?(l(t,e,i,s,r),l(t,e,s,n,r)):(l(t,e,s,n,r),l(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=c(i,e),u=a[0],d=a[1],g=c(n,e),p=g[0],m=g[1],v=f(u,d),w=v[0],y=v[1],b=f(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+e.toFixed(8)&&(x=u),Math.abs(p)===+e.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,e)},u=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.arcTo(e+n,i,e+n,i+o,o),t.lineTo(e+n,i+r-o),t.arcTo(e+n,i+r,e+n-o,i+r,o),t.lineTo(e+o,i+r),t.arcTo(e,i+r,e,i+r-o,o),t.lineTo(e,i+o),t.arcTo(e,i,e+o,i,o),t.closePath(),t.fill()},d=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},g=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},p=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(r(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,n.translate(this.Radius,this.Radius);var r=function(){e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},s=0,a=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){s++,a===s&&r.call(e)}))}))}))),a||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[e];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][e]=c,c.src=h.src,c.onload=function(){return i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.ctx,n=e._defaultConfig,r=e._defaultStyle;i.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,n){return i.beginPath(),i.fillStyle=n.background,i.arc(0,0,e,0,2*Math.PI,!1),i.fill(),e-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=h(this.prizeDeg);var o=h(-90+this.rotateDeg+n.offsetDegree),a=function(e){return t.getOffsetX(i.measureText(e).width)},f=function(e,i,n){var o=e.lineHeight||r.lineHeight||e.fontSize||r.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(o)};i.save(),this.prizes.forEach((function(e,u){var d=o+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){e||(e=o);var a=h(90/Math.PI/i*o),f=h(90/Math.PI/e*o),u=n+a,d=r-a,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,c(u,i)),l(t,i,u,d,!0),p>g?l(t,e,g,p,!1):t.lineTo.apply(t,c((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(i,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),e.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;i.translate(p,m),i.rotate(d+h(90)),e.imgs&&e.imgs.forEach((function(e,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,e,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];i.drawImage(r,t.getOffsetX(s),t.getHeight(e.top,g),s,a)}}})),e.fonts&&e.fonts.forEach((function(e){var o=e.fontColor||r.fontColor,h=e.fontWeight||r.fontWeight,c=t.getLength(e.fontSize||r.fontSize),l=e.fontStyle||r.fontStyle;i.fillStyle=o,i.font=h+" "+c+"px "+l;var u=[],d=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:r.wordWrap){d=s(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=i.measureText(p).width,w=(t.prizeRadius-f(e,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(e.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){i.fillText(t,a(t),f(e,g,n))}))})),i.rotate(h(360)-d-h(90)),i.translate(-p,-m)})),i.restore(),this.buttons.forEach((function(e,n){var o=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.arc(0,0,o,0,2*Math.PI,!1),i.fill(),e.pointer&&(i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.moveTo(-o,0),i.lineTo(o,0),i.lineTo(0,2*-o),i.closePath(),i.fill()),e.imgs&&e.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=h[0],f=h[1];i.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var n=e.fontColor||r.fontColor,s=e.fontWeight||r.fontWeight,h=t.getLength(e.fontSize||r.fontSize),c=e.fontStyle||r.fontStyle;i.fillStyle=n,i.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,n){i.fillText(t,a(t),f(e,o,n))}))}))}))},e.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.prizeFlag,o=e.prizeDeg,s=e.rotateDeg,a=e._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var f=360*c-r*o-s-a.offsetDegree;if(g(this.FPS,this.stopDeg,f,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=f;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+d(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopDeg,h=e.endDeg,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.rotateDeg=g(f,a,h,c.decelerationTime)%360,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(a),m=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,s=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),o=n[0],a=n[1],h=n[2],c=n[3];r.beginPath(),r.rect(o,a,h,c),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[e];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][e]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&i.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][e].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,a=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=r(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,s=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,s=0;switch(e.length){case 1:i=n=r=s=e[0];break;case 2:i=n=e[0],r=s=e[1];break;case 3:i=e[0],r=s=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],s=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&o(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,s]}(i).map((function(t){return~~t})),f=c[0],l=c[1],d=c[2],g=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return u(n,r,s,a,h,p,t.handleBackground(r,s,a,h,i.background)),{x:r+d,y:s+f,w:a-d-g,h:h-f-l}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],a=r[1],f=r[2],l=r[3],d=i===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===g.length&&(n.shadowColor=g[3],n.shadowOffsetX=g[0],n.shadowOffsetY=g[1],n.shadowBlur=g[2],g[0]>0?f-=g[0]:(f+=g[0],o-=g[0]),g[1]>0?l-=g[1]:(l+=g[1],a-=g[1])),u(n,o,a,f,l,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,a,f,l,e.background,d)),n.shadowColor="rgba(255, 255, 255, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,s){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][s];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),l=f[0],u=f[1];n.drawImage(c,o+t.getOffsetX(l,e.col),a+t.getHeight(r.top,e.row),l,u)})),e.fonts&&e.fonts.forEach((function(i){var r=d&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,f=d&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,l=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=f+" "+l+"px "+r,n.fillStyle=d&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=s(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,s){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(s+1)*t.getLength(u))}))}))}))},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var f=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),f)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.cAF,e=this.clearInterval;this.startTime||(e(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.currIndex,o=e.prizes,s=e.prizeFlag,a=e.startTime,h=e._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var f=0;++f;){var l=o.length*f+s-(r>>0);if(g(this.FPS,this.stopIndex,l,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=l;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+d(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopIndex,h=e.endIndex,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.currIndex=g(f,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(a);t.LuckyGrid=m,t.LuckyWheel=p,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
***************************************************************************** */var e=function(t,i){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,i)};function i(t,i){function n(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}var n=function(){return(n=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var r in e=arguments[i])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(){for(var t=0,e=0,i=arguments.length;e<i;e++)t+=arguments[e].length;var n=Array(t),r=0;for(e=0;e<i;e++)for(var o=arguments[e],s=0,a=o.length;s<a;s++,r++)n[r]=o[s];return n}var o=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return e.some((function(e){return Object.prototype.toString.call(t).slice(8,-1).toLowerCase()===e}))},s=function(t){return[].filter.call(t,(function(t){return"\n"!==t})).join("")},a=function(){function t(t){this.htmlFontSize=16,this.dpr=1,this.subs={},this.rAF=function(){},this.cAF=function(){},this.setInterval=function(){},this.clearInterval=function(){},this.setDpr(),this.setHTMLFontSize(),this.resetArrayProto(),this.initWindowFunction(),"string"==typeof t?t={el:t}:1===t.nodeType&&(t={el:"",divElement:t}),(t=t).el&&(t.divElement=document.querySelector(t.el)),t.divElement&&(t.width=t.divElement.offsetWidth,t.height=t.divElement.offsetHeight,t.canvasElement=document.createElement("canvas"),t.divElement.appendChild(t.canvasElement)),t.width&&(t.width=this.getLength(t.width)),t.height&&(t.height=this.getLength(t.height)),t.canvasElement&&(t.ctx=t.canvasElement.getContext("2d")),this.ctx=t.ctx,this.config=t,t.ctx&&t.width&&t.height}return t.prototype.setDpr=function(){window&&(window.dpr=this.dpr=1.3*(window.devicePixelRatio||2))},t.prototype.setHTMLFontSize=function(){window&&(this.htmlFontSize=+window.getComputedStyle(document.documentElement).fontSize.slice(0,-2))},t.prototype.initWindowFunction=function(){window&&(this.rAF=window.requestAnimationFrame,this.cAF=window.cancelAnimationFrame,this.setInterval=window.setInterval,this.clearInterval=window.clearInterval)},t.prototype.zoomCanvas=function(){var t=this,e=t.config,i=t.ctx,n=t.dpr,r=e.divElement,o=e.canvasElement,s=function(t){return(t*n-t)/(t*n)*(n/2)*100};r&&o&&(e.width=r.offsetWidth,e.height=r.offsetHeight,o.width=e.width*n,o.height=e.height*n,o.style.width=o.width+"px",o.style.height=o.height+"px",o.style.transform="scale("+1/n+") translate(\n "+-s(o.width)+"%, "+-s(o.height)+"%\n )",i.scale(n,n))},t.prototype.getLength=function(t){return o(t,"number")?t:o(t,"string")?this.changeUnits(t):0},t.prototype.changeUnits=function(t,e){var i=this;return void 0===e&&(e=1),Number(t.replace(/^(\-*[0-9.]*)([a-z%]*)$/,(function(t,n,r){switch(r){case"%":n*=e/100;break;case"px":n*=1;break;case"rem":n*=i.htmlFontSize;break;case"rpx":n=i.rpx2px(n);break;default:n*=1}return n})))},t.prototype.px2rpx=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?750/wx.getSystemInfoSync().windowWidth*t:t},t.prototype.rpx2px=function(t){return"string"==typeof t&&(t=Number(t.replace(/[a-z]*/g,""))),wx?wx.getSystemInfoSync().windowWidth/750*t:t},t.prototype.draw=function(){},t.prototype.observer=function(t){var e=this;t&&"object"==typeof t&&Object.keys(t).forEach((function(i){e.defineReactive(t,i,t[i])}))},t.prototype.defineReactive=function(t,e,i){var n=this;this.observer(i),Object.defineProperty(t,e,{get:function(){return i},set:function(t){var r=i;t!==i&&(i=t,n.observer(i),n.subs[e]&&n.subs[e].call(n,i,r),n.draw())}})},t.prototype.$set=function(t,e,i){t&&"object"==typeof t&&this.defineReactive(t,e,i)},t.prototype.$computed=function(t,e,i){var n=this;Object.defineProperty(t,e,{get:function(){return i.call(n)}})},t.prototype.$watch=function(t,e){this.subs[t]=e},t.prototype.resetArrayProto=function(){var t=this,e=Array.prototype,i=Object.create(e);["push","pop","shift","unshift","sort","splice","reverse"].forEach((function(n){i[n]=function(){var i;t.draw(),(i=e[n]).call.apply(i,r([this],Array.from(arguments)))}}))},t}(),h=function(t){return Math.PI/180*t},c=function(t,e){return[+(Math.cos(t)*e).toFixed(8),+(Math.sin(t)*e).toFixed(8)]},f=function(t,e){var i=-t/e;return[i,-i*t+e]},l=function(t,e,i,n,r){var o;if(void 0===r&&(r=!0),Math.abs(n-i).toFixed(8)>=h(180).toFixed(8)){var s=(n+i)/2;return r?(l(t,e,i,s,r),l(t,e,s,n,r)):(l(t,e,s,n,r),l(t,e,i,s,r)),!1}r||(i=(o=[n,i])[0],n=o[1]);var a=c(i,e),u=a[0],d=a[1],g=c(n,e),p=g[0],m=g[1],v=f(u,d),w=v[0],y=v[1],b=f(p,m),z=b[0],S=b[1],x=(S-y)/(w-z),I=(z*y-w*S)/(z-w);isNaN(x)&&(Math.abs(u)===+e.toFixed(8)&&(x=u),Math.abs(p)===+e.toFixed(8)&&(x=p)),w===1/0||w===-1/0?I=z*x+S:z!==1/0&&z!==-1/0||(I=w*x+y),t.lineTo(u,d),t.arcTo(x,I,p,m,e)},u=function(t,e,i,n,r,o,s){var a=Math.min(n,r);o>a/2&&(o=a/2),t.beginPath(),t.fillStyle=s,t.moveTo(e+o,i),t.lineTo(e+o,i),t.lineTo(e+n-o,i),t.arcTo(e+n,i,e+n,i+o,o),t.lineTo(e+n,i+r-o),t.arcTo(e+n,i+r,e+n-o,i+r,o),t.lineTo(e+o,i+r),t.arcTo(e,i+r,e,i+r-o,o),t.lineTo(e,i+o),t.arcTo(e,i,e+o,i,o),t.closePath(),t.fill()},d=function(t,e,i,n){return t>=n&&(t=n),i*(t/=n)*t+e},g=function(t,e,i,n){return t>=n&&(t=n),-i*(t/=n)*(t-2)+e},p=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.blocks=[],n.prizes=[],n.buttons=[],n.defaultConfig={},n._defaultConfig={gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",wordWrap:!0,lengthLimit:"90%"},n.Radius=0,n.prizeRadius=0,n.prizeDeg=0,n.prizeRadian=0,n.rotateDeg=0,n.maxBtnRadius=0,n.startTime=0,n.endTime=0,n.stopDeg=0,n.endDeg=0,n.animationId=0,n.FPS=16.6,n.prizeImgs=[[]],n.btnImgs=[[]],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.buttons&&r.push.apply(r,n.buttons.map((function(t){return t.imgs}))),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"buttons",t.buttons||[]),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){return n({gutter:"0px",offsetDegree:0,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig)})),this.$computed(this,"_defaultStyle",(function(){return n({fontSize:"18px",fontColor:"#000",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.prizeImgs[r]&&t.prizeImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("buttons",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s&&s.imgs?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.btnImgs[r]&&t.btnImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(r(new Array(t.prizes.length).fill(void 0),n))}))},e.prototype.init=function(t){var e=this,i=this.config,n=this.ctx;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas(),this.Radius=Math.min(i.width,i.height)/2,n.translate(this.Radius,this.Radius);var r=function(){e.draw(),i.canvasElement&&(i.canvasElement.onclick=function(t){var i;n.beginPath(),n.arc(0,0,e.maxBtnRadius,0,2*Math.PI,!1),n.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},s=0,a=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){a++,e.loadAndCacheImg(i,n,(function(){s++,a===s&&r.call(e)}))}))}))),a||r.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=t<this.prizes.length,o=r?"prizes":"buttons",s=r?"prizeImgs":"btnImgs";t=r?t:t-this.prizes.length;var a=this[o][t];if(a&&a.imgs){var h=a.imgs[e];if(h){var c=new Image;this[s][t]||(this[s][t]=[]),this[s][t][e]=c,c.src=h.src,c.onload=function(){return i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i,n){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var r=this.getWidth(e.width,i);return[r,t.height*(r/t.width)]}if(!e.width&&e.height){var o=this.getHeight(e.height,n);return[t.width*(o/t.height),o]}return[this.getWidth(e.width,i),this.getHeight(e.height,n)]},e.prototype.draw=function(){var t=this,e=this,i=e.ctx,n=e._defaultConfig,r=e._defaultStyle;i.clearRect(-this.Radius,-this.Radius,2*this.Radius,2*this.Radius),this.prizeRadius=this.blocks.reduce((function(e,n){return i.beginPath(),i.fillStyle=n.background,i.arc(0,0,e,0,2*Math.PI,!1),i.fill(),e-t.getLength(n.padding.split(" ")[0])}),this.Radius),this.prizeDeg=360/this.prizes.length,this.prizeRadian=h(this.prizeDeg);var o=h(-90+this.rotateDeg+n.offsetDegree),a=function(e){return t.getOffsetX(i.measureText(e).width)},f=function(e,i,n){var o=e.lineHeight||r.lineHeight||e.fontSize||r.fontSize;return t.getHeight(e.top,i)+(n+1)*t.getLength(o)};i.save(),this.prizes.forEach((function(e,u){var d=o+u*t.prizeRadian,g=t.prizeRadius-t.maxBtnRadius;!function(t,e,i,n,r,o,s){e||(e=o);var a=h(90/Math.PI/i*o),f=h(90/Math.PI/e*o),u=n+a,d=r-a,g=n+f,p=r-f;t.beginPath(),t.fillStyle=s,t.moveTo.apply(t,c(u,i)),l(t,i,u,d,!0),p>g?l(t,e,g,p,!1):t.lineTo.apply(t,c((n+r)/2,o/2/Math.abs(Math.sin((n-r)/2)))),t.closePath(),t.fill()}(i,t.maxBtnRadius,t.prizeRadius,d-t.prizeRadian/2,d+t.prizeRadian/2,t.getLength(n.gutter),e.background||r.background||"rgba(0, 0, 0, 0)");var p=Math.cos(d)*t.prizeRadius,m=Math.sin(d)*t.prizeRadius;i.translate(p,m),i.rotate(d+h(90)),e.imgs&&e.imgs.forEach((function(e,n){if(t.prizeImgs[u]){var r=t.prizeImgs[u][n];if(r){var o=t.computedWidthAndHeight(r,e,t.prizeRadian*t.prizeRadius,g),s=o[0],a=o[1];i.drawImage(r,t.getOffsetX(s),t.getHeight(e.top,g),s,a)}}})),e.fonts&&e.fonts.forEach((function(e){var o=e.fontColor||r.fontColor,h=e.fontWeight||r.fontWeight,c=t.getLength(e.fontSize||r.fontSize),l=e.fontStyle||r.fontStyle;i.fillStyle=o,i.font=h+" "+c+"px "+l;var u=[],d=String(e.text);if(e.hasOwnProperty("wordWrap")?e.wordWrap:r.wordWrap){d=s(d);for(var p="",m=0;m<d.length;m++){p+=d[m];var v=i.measureText(p).width,w=(t.prizeRadius-f(e,g,u.length))*Math.tan(t.prizeRadian/2)*2-t.getLength(n.gutter);v>t.getWidth(e.lengthLimit||r.lengthLimit,w)&&(u.push(p.slice(0,-1)),p=d[m])}p&&u.push(p),u.length||u.push(d)}else u=d.split("\n");u.filter((function(t){return!!t})).forEach((function(t,n){i.fillText(t,a(t),f(e,g,n))}))})),i.rotate(h(360)-d-h(90)),i.translate(-p,-m)})),i.restore(),this.buttons.forEach((function(e,n){var o=t.getHeight(e.radius);t.maxBtnRadius=Math.max(t.maxBtnRadius,o),i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.arc(0,0,o,0,2*Math.PI,!1),i.fill(),e.pointer&&(i.beginPath(),i.fillStyle=e.background||"rgba(0, 0, 0, 0)",i.moveTo(-o,0),i.lineTo(o,0),i.lineTo(0,2*-o),i.closePath(),i.fill()),e.imgs&&e.imgs.forEach((function(r,s){if(t.btnImgs[n]){var a=t.btnImgs[n][s];if(a){var h=t.computedWidthAndHeight(a,r,2*t.getHeight(e.radius),2*t.getHeight(e.radius)),c=h[0],f=h[1];i.drawImage(a,t.getOffsetX(c),t.getHeight(r.top,o),c,f)}}})),e.fonts&&e.fonts.forEach((function(e){var n=e.fontColor||r.fontColor,s=e.fontWeight||r.fontWeight,h=t.getLength(e.fontSize||r.fontSize),c=e.fontStyle||r.fontStyle;i.fillStyle=n,i.font=s+" "+h+"px "+c,String(e.text).split("\n").forEach((function(t,n){i.fillText(t,a(t),f(e,o,n))}))}))}))},e.prototype.play=function(){var t=this.cAF;this.startTime||(t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=Number(t)%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.prizeFlag,o=e.prizeDeg,s=e.rotateDeg,a=e._defaultConfig,h=Date.now()-this.startTime;if(h>=a.accelerationTime&&void 0!==r){this.FPS=h/t,this.endTime=Date.now(),this.stopDeg=s;for(var c=0;++c;){var f=360*c-r*o-s-a.offsetDegree;if(g(this.FPS,this.stopDeg,f,a.decelerationTime)-this.stopDeg>a.speed){this.endDeg=f;break}}return n(this.animationId),this.slowDown()}this.rotateDeg=(s+d(h,0,a.speed,a.accelerationTime))%360,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopDeg,h=e.endDeg,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>=c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.rotateDeg=g(f,a,h,c.decelerationTime)%360,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.getWidth=function(t,e){return void 0===e&&(e=this.prizeRadian*this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=this.prizeRadius),o(t,"number")?t:o(t,"string")?this.changeUnits(t,e):0},e.prototype.getOffsetX=function(t){return-t/2},e}(a),m=function(t){function e(e,i){void 0===i&&(i={});var n=t.call(this,e)||this;n.rows=3,n.cols=3,n.blocks=[],n.prizes=[],n.defaultConfig={},n._defaultConfig={gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},n.defaultStyle={},n._defaultStyle={borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",lineHeight:"",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},n.activeStyle={},n._activeStyle={background:"#ffce98",shadow:"",fontStyle:"",fontWeight:"",fontSize:"",lineHeight:"",fontColor:""},n.cellWidth=0,n.cellHeight=0,n.startTime=0,n.endTime=0,n.currIndex=0,n.stopIndex=0,n.endIndex=0,n.demo=!1,n.timer=0,n.animationId=0,n.FPS=16.6,n.cells=[],n.cellImgs=[],n.initData(i),n.initComputed(),n.initWatch();var r=[[]];return n.prizes&&(r=n.prizes.map((function(t){return t.imgs}))),n.button&&(r[n.cols*n.rows-1]=n.button.imgs),n.init(r),n}return i(e,t),e.prototype.initData=function(t){this.$set(this,"rows",Number(t.rows)||3),this.$set(this,"cols",Number(t.cols)||3),this.$set(this,"blocks",t.blocks||[]),this.$set(this,"prizes",t.prizes||[]),this.$set(this,"button",t.button),this.$set(this,"defaultConfig",t.defaultConfig||{}),this.$set(this,"defaultStyle",t.defaultStyle||{}),this.$set(this,"activeStyle",t.activeStyle||{}),this.$set(this,"startCallback",t.start),this.$set(this,"endCallback",t.end)},e.prototype.initComputed=function(){var t=this;this.$computed(this,"_defaultConfig",(function(){var e=n({gutter:5,speed:20,accelerationTime:2500,decelerationTime:2500},t.defaultConfig);return e.gutter=t.getLength(e.gutter),e.speed=e.speed/40,e})),this.$computed(this,"_defaultStyle",(function(){return n({borderRadius:20,fontColor:"#000",fontSize:"18px",fontStyle:"microsoft yahei ui,microsoft yahei,simsun,sans-serif",fontWeight:"400",background:"#fff",shadow:"",wordWrap:!0,lengthLimit:"90%"},t.defaultStyle)})),this.$computed(this,"_activeStyle",(function(){return n({background:"#ffce98",shadow:""},t.activeStyle)}))},e.prototype.initWatch=function(){var t=this;this.$watch("prizes",(function(e,i){var n=[];return i?e&&e.forEach((function(e,r){var o=[],s=i[r];s?e.imgs&&e.imgs.forEach((function(e,i){if(!s.imgs)return o[i]=e;var n=s.imgs[i];n&&t.cellImgs[r][i]?e.src!==n.src&&(o[i]=e):o[i]=e})):o=e.imgs||[],n[r]=o})):n=e.map((function(t){return t.imgs})),t.init(n)})),this.$watch("button",(function(e,i){var n=[],r=t.cols*t.rows-1;if(i&&i.imgs){if(e.imgs){var o=[];e.imgs.forEach((function(e,n){if(!i.imgs)return o[n]=e;var s=i.imgs[n];s&&t.cellImgs[r][n]?e.src!==s.src&&(o[n]=e):o[n]=e})),n[r]=o}}else n[r]=e.imgs;return t.init(n)}))},e.prototype.init=function(t){var e=this,i=this,n=i.config,r=i.ctx,s=i.button;this.setDpr(),this.setHTMLFontSize(),this.zoomCanvas();var a=function(){e.draw(),e.demo&&e.walk(),s&&n.canvasElement&&(n.canvasElement.onclick=function(t){var i,n=e.getGeometricProperty([s.x,s.y,s.col||1,s.row||1]),o=n[0],a=n[1],h=n[2],c=n[3];r.beginPath(),r.rect(o,a,h,c),r.isPointInPath(t.offsetX,t.offsetY)&&(e.startTime||null===(i=e.startCallback)||void 0===i||i.call(e,t))})},h=0,c=0;o(t,"array")&&(this.draw(),t.forEach((function(t,i){if(!t)return!1;t.forEach((function(t,n){c++,e.loadAndCacheImg(i,n,(function(){h++,c===h&&a.call(e)}))}))}))),c||a.call(this)},e.prototype.loadAndCacheImg=function(t,e,i){var n=this,r=this.cells[t];if(r&&r.imgs){var o=r.imgs[e];this.cellImgs[t]||(this.cellImgs[t]=[]);var s=new Image;this.cellImgs[t][e]={defaultImg:s},s.src=o.src;var a=0,h=1;if(s.onload=function(){++a===h&&i.call(n)},o.hasOwnProperty("activeSrc")){h++;var c=new Image;this.cellImgs[t][e].activeImg=c,c.src=o.activeSrc,c.onload=function(){++a===h&&i.call(n)}}}},e.prototype.computedWidthAndHeight=function(t,e,i){if(!e.width&&!e.height)return[t.width,t.height];if(e.width&&!e.height){var n=this.getWidth(e.width,i.col);return[n,t.height*(n/t.width)]}if(!e.width&&e.height){var r=this.getHeight(e.height,i.row);return[t.width*(r/t.height),r]}return[this.getWidth(e.width,i.col),this.getHeight(e.height,i.row)]},e.prototype.draw=function(){var t=this,e=this,i=e.config,n=e.ctx,a=e._defaultConfig,h=e._defaultStyle,c=e._activeStyle;n.clearRect(0,0,i.width,i.height),this.cells=r(this.prizes),this.button&&(this.cells[this.cols*this.rows-1]=this.button),this.cells.forEach((function(t){t.col=t.col||1,t.row=t.row||1})),this.prizeArea=this.blocks.reduce((function(e,i){var r=e.x,s=e.y,a=e.w,h=e.h,c=function(t){var e=t.padding.replace(/px/g,"").split(" ").map((function(t){return~~t}))||[0],i=0,n=0,r=0,s=0;switch(e.length){case 1:i=n=r=s=e[0];break;case 2:i=n=e[0],r=s=e[1];break;case 3:i=e[0],r=s=e[1],n=e[2];break;default:i=e[0],n=e[1],r=e[2],s=e[3]}var a={paddingTop:i,paddingBottom:n,paddingLeft:r,paddingRight:s};for(var h in a)a[h]=t.hasOwnProperty(h)&&o(t[h],"string","number")?~~String(t[h]).replace(/px/g,""):a[h];return[i,n,r,s]}(i).map((function(t){return~~t})),f=c[0],l=c[1],d=c[2],g=c[3],p=i.borderRadius?t.getLength(i.borderRadius):0;return u(n,r,s,a,h,p,t.handleBackground(r,s,a,h,i.background)),{x:r+d,y:s+f,w:a-d-g,h:h-f-l}}),{x:0,y:0,w:i.width,h:i.height}),this.cellWidth=(this.prizeArea.w-a.gutter*(this.cols-1))/this.cols,this.cellHeight=(this.prizeArea.h-a.gutter*(this.rows-1))/this.rows,this.cells.forEach((function(e,i){var r=t.getGeometricProperty([e.x,e.y,e.col,e.row]),o=r[0],a=r[1],f=r[2],l=r[3],d=i===t.currIndex%t.prizes.length>>0,g=(d?c.shadow:e.shadow||h.shadow).replace(/px/g,"").split(",")[0].split(" ").map((function(t,e){return e<3?Number(t):t}));4===g.length&&(n.shadowColor=g[3],n.shadowOffsetX=g[0],n.shadowOffsetY=g[1],n.shadowBlur=g[2],g[0]>0?f-=g[0]:(f+=g[0],o-=g[0]),g[1]>0?l-=g[1]:(l+=g[1],a-=g[1])),u(n,o,a,f,l,t.getLength(e.borderRadius?e.borderRadius:h.borderRadius),t.handleBackground(o,a,f,l,e.background,d)),n.shadowColor="rgba(255, 255, 255, 0)",n.shadowOffsetX=0,n.shadowOffsetY=0,n.shadowBlur=0,e.imgs&&e.imgs.forEach((function(r,s){if(!t.cellImgs[i])return!1;var h=t.cellImgs[i][s];if(!h)return!1;var c=d&&h.activeImg||h.defaultImg,f=t.computedWidthAndHeight(c,r,e),l=f[0],u=f[1];n.drawImage(c,o+t.getOffsetX(l,e.col),a+t.getHeight(r.top,e.row),l,u)})),e.fonts&&e.fonts.forEach((function(i){var r=d&&c.fontStyle?c.fontStyle:i.fontStyle||h.fontStyle,f=d&&c.fontWeight?c.fontWeight:i.fontWeight||h.fontWeight,l=d&&c.fontSize?t.getLength(c.fontSize):t.getLength(i.fontSize||h.fontSize),u=d&&c.lineHeight?c.lineHeight:i.lineHeight||h.lineHeight||i.fontSize||h.fontSize;n.font=f+" "+l+"px "+r,n.fillStyle=d&&c.fontColor?c.fontColor:i.fontColor||h.fontColor;var g=[],p=String(i.text);if(i.hasOwnProperty("wordWrap")?i.wordWrap:h.wordWrap){p=s(p);for(var m="",v=0;v<p.length;v++){m+=p[v],n.measureText(m).width>t.getWidth(i.lengthLimit||h.lengthLimit,e.col)&&(g.push(m.slice(0,-1)),m=p[v])}m&&g.push(m),g.length||g.push(p)}else g=p.split("\n");g.forEach((function(r,s){n.fillText(r,o+t.getOffsetX(n.measureText(r).width,e.col),a+t.getHeight(i.top,e.row)+(s+1)*t.getLength(u))}))}))}))},e.prototype.handleBackground=function(t,e,i,n,r,o){void 0===o&&(o=!1);var s=this,a=s.ctx,h=s._defaultStyle,c=s._activeStyle;return(r=o?c.background:r||h.background).includes("linear-gradient")&&(r=function(t,e,i,n,r,o){var s=/linear-gradient\((.+)\)/.exec(o)[1].split(",").map((function(t){return t.trim()})),a=s.shift(),h=[0,0,0,0];if(a.includes("deg")){var c=function(t){return Math.tan(t/180*Math.PI)};(a=a.slice(0,-3)%360)>=0&&a<45?h=[e,i+r,e+n,i+r-n*c(a-0)]:a>=45&&a<90?h=[e,i+r,e+n-r*c(a-45),i]:a>=90&&a<135?h=[e+n,i+r,e+n-r*c(a-90),i]:a>=135&&a<180?h=[e+n,i+r,e,i+n*c(a-135)]:a>=180&&a<225?h=[e+n,i,e,i+n*c(a-180)]:a>=225&&a<270?h=[e+n,i,e+r*c(a-225),i+r]:a>=270&&a<315?h=[e,i,e+r*c(a-270),i+r]:a>=315&&a<360&&(h=[e,i,e+n,i+r-n*c(a-315)])}else a.includes("top")?h=[e,i+r,e,i]:a.includes("bottom")?h=[e,i,e,i+r]:a.includes("left")?h=[e+n,i,e,i]:a.includes("right")&&(h=[e,i,e+n,i]);var f=t.createLinearGradient.apply(t,h.map((function(t){return t>>0})));return s.reduce((function(t,e,i){var n=e.split(" ");return 1===n.length?t.addColorStop(i,n[0]):2===n.length&&t.addColorStop.apply(t,n),t}),f)}(a,t,e,i,n,r)),r},e.prototype.play=function(){var t=this.cAF,e=this.clearInterval;this.startTime||(e(this.timer),t(this.animationId),this.startTime=Date.now(),this.prizeFlag=void 0,this.run())},e.prototype.stop=function(t){this.prizeFlag=t%this.prizes.length},e.prototype.run=function(t){void 0===t&&(t=0);var e=this,i=e.rAF,n=e.cAF,r=e.currIndex,o=e.prizes,s=e.prizeFlag,a=e.startTime,h=e._defaultConfig,c=Date.now()-a;if(c>=h.accelerationTime&&void 0!==s){this.FPS=c/t,this.endTime=Date.now(),this.stopIndex=r;for(var f=0;++f;){var l=o.length*f+s-(r>>0);if(g(this.FPS,this.stopIndex,l,h.decelerationTime)-this.stopIndex>h.speed){this.endIndex=l;break}}return n(this.animationId),this.slowDown()}this.currIndex=(r+d(c,.1,h.speed,h.accelerationTime))%o.length,this.draw(),this.animationId=i(this.run.bind(this,t+1))},e.prototype.slowDown=function(){var t,e=this,i=e.rAF,r=e.cAF,o=e.prizes,s=e.prizeFlag,a=e.stopIndex,h=e.endIndex,c=e._defaultConfig,f=Date.now()-this.endTime;if(f>c.decelerationTime)return this.startTime=0,null===(t=this.endCallback)||void 0===t||t.call(this,n({},o.find((function(t,e){return e===s})))),r(this.animationId);this.currIndex=g(f,a,h,c.decelerationTime)%o.length,this.draw(),this.animationId=i(this.slowDown.bind(this))},e.prototype.walk=function(){var t=this,e=this.setInterval;(0,this.clearInterval)(this.timer),this.timer=e((function(){t.currIndex+=1,t.draw()}),1300)},e.prototype.getGeometricProperty=function(t){var e=t[0],i=t[1],n=t[2],r=t[3],o=this.cellWidth,s=this.cellHeight,a=this._defaultConfig.gutter,h=[this.prizeArea.x+(o+a)*e,this.prizeArea.y+(s+a)*i];return n&&r&&h.push(o*n+a*(n-1),s*r+a*(r-1)),h},e.prototype.getWidth=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellWidth*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getHeight=function(t,e){return void 0===e&&(e=1),o(t,"number")?t:o(t,"string")?this.changeUnits(t,this.cellHeight*e+this._defaultConfig.gutter*(e-1)):0},e.prototype.getOffsetX=function(t,e){return void 0===e&&(e=1),(this.cellWidth*e+this._defaultConfig.gutter*(e-1)-t)/2},e}(a);t.LuckyGrid=m,t.LuckyWheel=p,Object.defineProperty(t,"__esModule",{value:!0})})); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
225919
3577