第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何設(shè)置指針停下后,中獎(jiǎng)區(qū)域的顏色會(huì)改變,在$(document).ready(function()函數(shù)中設(shè)置了不起作用

如何設(shè)置指針停下后,中獎(jiǎng)區(qū)域的顏色會(huì)改變,在$(document).ready(function()函數(shù)中設(shè)置了不起作用

jugge 2017-02-28 20:36:25
<html> ?????<head> ?????????<meta?charset="utf-8"/> ?????????<title></title> ?????????<style?type="text/css"> ?????????????*{margin:?0;padding:?0;} ?????????????.clear{clear:both;} ?????????????.banner{width:?550px;height:?550px;margin:?25px?auto;} ?????????????.turnplate{width:?100%;height:?100%;position:?relative;} ?????????????.banner?.turnplate?canvas.item{width:100%;} ?????????????.turnplate?img.pointer{position:?absolute;width:31.5%;height:42.5%;left:34.6%;top:23.5%;}??????????? ?????????</style> ?????????<script?type="text/javascript"?src="js/jquery-1.10.2.js"></script> ?????????<script?type="text/javascript"?src="js/awardRotate.js"></script>???????? ?????????<script?type="text/javascript"> ?????????????var?turnplate={ ?????????????????????restaraunts:[],???????????? ?????????????????????colors:[], ?????????????????????outsideRadius:192, ?????????????????????textRadius:155, ?????????????????????insideRadius:63, ?????????????????????startAngle:0,?? ?????????????????????bRotate:false ?????????????}; ?????????$(document).ready(function(){ ?????????????turnplate.restaraunts?=?["白妖子",?"黃妖子",?"藍(lán)妖子",?"紫妖子",?"橘妖子",?"綠妖子",?"黑妖子?",?"棕妖子",?"紅妖子",?"粉妖子"]; ?????????????turnplate.colors?=?["#FFF4D6",?"#FFFFFF",?"#FFF4D6",? "#FFFFFF","#FFF4D6",?"#FFFFFF",?"#FFF4D6",?"#FFFFFF","#FFF4D6",? "#FFFFFF"]; ?????????????var?rotateFn?=?function?(item,?txt){ ?????????????????var?angles?=?item?*?(360?/?turnplate.restaraunts.length)?-?(360?/?(turnplate.restaraunts.length*2)); ?????????????????if(angles<270){ ?????????????????????angles?=?270?-?angles;? ?????????????????}else{ ?????????????????????angles?=?360?-?angles?+?270; ?????????????????} ?????????????????$('#wheelcanvas').stopRotate(); ?????????????????$('#wheelcanvas').rotate({ ?????????????????????angle:0, ?????????????????????animateTo:angles+1800, ?????????????????????duration:8000, ?????????????????????callback:function?(){???????????????????????? ?????????????????????????turnplate.bRotate?=?!turnplate.bRotate; ?????????????????????????for(var?i=0;i<turnplate.colors;i++){ ?????????????????????????if(txt.indexOf("白")==0){turnplate.colors='red';} ?????????????????????????else{turnplate.colors='#FF69B4';} ?????????????????????????}?????????????????????? ?????????????????????} ?????????????????}); ?????????????????console.log(txt)?; ?????????????};????????????? ?????????????turnplate.colors[1]='red';???????????? ?????????????$('.pointer').click(function?pointer?(){ ?????????????????if(turnplate.bRotate)return; ?????????????????turnplate.bRotate?=?!turnplate.bRotate; ?????????????????var?item?=?rnd(1,turnplate.restaraunts.length); ?????????????????rotateFn(item,?turnplate.restaraunts[item-1]); ?????????????????console.log(item); ?????????????}); ?????????});???? ?????????function?rnd(n,?m){ ?????????????var?random?=?Math.floor(Math.random()*(m-n+1)+n); ?????????????return?random;???????? ?????????}??????????? ?????????window.onload=function(){ ?????????????drawRouletteWheel(); ?????????};??????? ?????????function?drawRouletteWheel()?{???? ???????????????var?canvas?=?document.getElementById("wheelcanvas");???? ???????????????if?(canvas.getContext)?{ ???????????????????var?arc?=?Math.PI?/?(turnplate.restaraunts.length/2); ???????????????????var?ctx?=?canvas.getContext("2d"); ???????????????????ctx.clearRect(0,0,422,422); ???????????????????ctx.strokeStyle?=?"#FFBE04"; ???????????????????ctx.font?=?'16px?Microsoft?YaHei';?????? ???????????????????for(var?i?=?0;?i?<?turnplate.restaraunts.length;?i++)?{??????? ???????????????????????var?angle?=?turnplate.startAngle?+?i?*?arc; ???????????????????????ctx.fillStyle?=?turnplate.colors[i]; ???????????????????????ctx.beginPath();??? ???????????????????????ctx.arc(211,?211,?turnplate.outsideRadius,?angle,?angle?+?arc,?false);???? ???????????????????????ctx.arc(211,?211,?turnplate.insideRadius,?angle?+?arc,?angle,?true); ???????????????????????ctx.stroke();?? ???????????????????????ctx.fill(); ???????????????????????ctx.save();????????????????????? ?????????????????ctx.fillStyle?=?"#E5302F"; ?????????????????var?text?=?turnplate.restaraunts[i]; ?????????????????var?line_height?=?17; ?????????????????ctx.translate(211?+?Math.cos(angle?+?arc?/?2)?*? turnplate.textRadius,?211?+?Math.sin(angle?+?arc?/?2)?*? turnplate.textRadius); ?????????????????ctx.rotate(angle?+?arc?/?2?+?Math.PI?/?2);?????????? ?????????????????if(text.indexOf("白")==0){ ???????????????????????ctx.fillStyle='white';????????????????????? ?????????????????????ctx.fillText(text,?-ctx.measureText(text).width?/?2,?0); ?????????????????}else ?????????????????{????ctx.fillStyle='yellow'; ?????????????????????ctx.fillText(text,?-ctx.measureText(text).width?/?2,?0); ?????????????????}????????????????? ???????????????????ctx.restore(); ?????????????}????? ?????????}? ?????????}???????? ?????????</script> ?????</head> ?????<body?style="background:#e62d2d;overflow-x:hidden;"> ?????????<img?src="images/1.png"?id="shan-img"?style="display:none;"?/> ?????????<img?src="images/2.png"?id="sorry-img"?style="display:none;"?/> ?????????<div> ?????????????<div?style="background-image:url(images/turnplate-bg.png);background-size:100%?100%;"> ?????????????????<canvas?id="wheelcanvas"?width="422px"?height="422px"></canvas> ?????????????????<img?src="images/turnplate-pointer.png"/> ?????????????</div> ?????????</div>??? ?????????<div?style="text-align:center;margin:50px?0;?font:normal?14px/24px?'MicroSoft?YaHei';">?????? ?????</body> ?</html>
查看完整描述

1 回答

?
依然c

TA貢獻(xiàn)54條經(jīng)驗(yàn) 獲得超32個(gè)贊

script寫在body的末尾好點(diǎn)點(diǎn)。我沒仔細(xì)看代碼啊,只知道應(yīng)該是在canvas里面,轉(zhuǎn)盤用的是canvas的圓把,指針也是計(jì)算角度把,指針記錄下那個(gè)角度,然后在canvas的圓上對(duì)稱畫出來,比如停在15度,那你畫0到30度,ctx.arc(211,211,半徑, 0, 1/6 * Math.PI); ?大概是這么個(gè)思路

查看完整回答
反對(duì) 回復(fù) 2017-03-01
  • jugge
    jugge
    主要是判斷最后停的這個(gè)區(qū)域應(yīng)該畫什么顏色 ,根據(jù)所在區(qū)域的文本指定的顏色來設(shè)置的,必須轉(zhuǎn)到紅色字,最后指針?biāo)趨^(qū)域改為紅色。var rotateFn = function (item, txt){}在這個(gè)函數(shù)外面指定顏色可以改變,但是獲取不到最后指針?biāo)诘奈谋局?,不能根?jù)文本值指定的顏色值來改變顏色
  • 依然c
    依然c
    指針角度總知道的吧,多少度為什么顏色規(guī)定好不就行了么
  • jugge
    jugge
    轉(zhuǎn)前都是"#FFF4D6", "#FFFFFF"這兩種顏色,是想等轉(zhuǎn)完后,指針指的黑妖子,這塊區(qū)域顏色就變成黑色;指的是紅妖子,這塊區(qū)域就變成紅色,轉(zhuǎn)停之前顏色都是初始默認(rèn)的#FFF4D6", "#FFFFFF
點(diǎn)擊展開后面1
  • 1 回答
  • 0 關(guān)注
  • 1778 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)