canvas 旋轉角度不需要累加

2019-8-24 16:01| 作者: admin| 查看: 3351| 評論: 0|來自: 螞蟻部落

RUGUONINGANJUEYIXIEDAIMABIJIAOQIGUAI,KENENGYOURUXIAJIZHONGKENENG:

(1).DAIMAQUESHIBIJIAOQIGUAI。

(2).DUIYUDAIMAYUANLIBUGOULEJIE。

BENWENFENXIANGYIDUANTONGGUOcanvasHUIZHIXUANZHUANTUANDEDAIMA。

TASHIXIANLEMEIGEZHIDINGSHIJIANXUANZHUANYIDINGJIAODUDEGONGNENG,DAIMASHILIRUXIA:

[HTML] 純文本查看 復制代碼运行代码
<!DOCTYPE html>  
<html>  
<head>  
<meta charset=" utf-8">  
<meta name="author" content="http://glbcf.cn/" />  
<title>螞蟻部落</title>
<style>
canvas{
  border:1px solid black;
}  
</style>
<script>
window.onload = () => {
  let cvs=document.getElementById("ant");
  let ctx=cvs.getContext("2d");
 
  ctx.translate(100,50);
  let angle=10;
 
  let rotate = () => {
    ctx.clearRect(-100,-50,200,100);
    ctx.rotate(angle*Math.PI/180);
  
    ctx.fillRect(-50,-25,100,50);
    setTimeout(rotate,16);
  }
  rotate()
}
</script>
</head>
<body>
<canvas id="ant"></canvas>
</body>
</html>

秒速赛车打不开SHANGSHUDAIMASHIXIANLEJUXINGTUANDEXUANZHUANXIAOGUO。

DANSHIYOUMEIYOUFAXIANYIGEQIGUAIDEXIANXIANG,JIAODUBUYONGLEIJIA。

秒速赛车打不开BIRUQITAXIAOGUORUGUOXUYAOSHIXIANZHEZHONGLEISIDEXIAOGUO,KENENGXUYAOa=a+1LEISILEIJIA。

秒速赛车打不开ZHESHIYINWEIrotate()XUANZHUANSHIDUIZUOBIAOXIDEXUANZHUAN,KEYIRENWEIMEIYICIXUANZHUANHOUDOU"GUILING"。

ZAICIXUANZHUANJIUYIXINDEZUOBIAOXIWEICANKAO,ERBUSHIYIZUICHUDEZUOBIAOXIWEICANKAO,SUOYIWUXUJINXINGLEIJIA。


鮮花

握手

雷人

路過

雞蛋

最新評論

返回頂部