這篇文章將為大家詳細講解有關(guān)Canvas如何制作旋轉(zhuǎn)太極的動畫,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
在黔西等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都做網(wǎng)站、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作按需規(guī)劃網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)營銷推廣,成都外貿(mào)網(wǎng)站建設(shè)公司,黔西網(wǎng)站建設(shè)費用合理。
前言
好久沒動canvas了,今下午突然想回顧一下,就寫了個旋轉(zhuǎn)的太極,哈哈,蠻好玩的,在這里就將自己寫的過程展示出來,旋轉(zhuǎn)使用的css實現(xiàn)的,沒有用canvas自己的,希望大佬們不要吐槽。
css
body{ background: #ddd; } #canvas{ position: absolute; left: 40%; top: 30%; -webkit-transform: translate(-50%,-50%); -moz-transform: translate(-50%,-50%); -ms-transform: translate(-50%,-50%); -o-transform: translate(-50%,-50%); transform: translate(-50%,-50%); -webkit-animation: testAnimate 3s linear infinite; -o-animation: testAnimate 3s linear infinite; animation: testAnimate 3s linear infinite; } @keyframes testAnimate { from { -webkit-transform: rotate(0); -moz-transform: rotate(0); -ms-transform: rotate(0); -o-transform: rotate(0); transform: rotate(0); } to { -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-transform: rotate(360deg); -o-transform: rotate(360deg); transform: rotate(360deg); } }
html
<body> <canvas id="canvas" width="500" height="500"></canvas> </body>
js
let ctx = document .getElementById("canvas") .getContext("2d"); // left-black-big ctx.beginPath(); ctx.fillStyle = "#000"; ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,false); ctx.closePath(); ctx.fill(); // right-white-big ctx.beginPath(); ctx.fillStyle = "#fff"; ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,true); ctx.closePath(); ctx.fill(); // top-black-middle ctx.beginPath(); ctx.fillStyle = "#000"; ctx.arc(250,150,100,Math.PI/2,Math.PI*1.5,true); ctx.closePath(); ctx.fill(); // bottom-white-middle ctx.beginPath(); ctx.fillStyle = "#fff"; ctx.arc(250,350,100,Math.PI/2,Math.PI*1.5,false); ctx.closePath(); ctx.fill(); // top-white-small ctx.beginPath(); ctx.fillStyle = "#fff"; ctx.arc(250,150,25,0,Math.PI*2); ctx.closePath(); ctx.fill(); // bottom-black-small ctx.beginPath(); ctx.fillStyle = "#000"; ctx.arc(250,350,25,0,Math.PI*2); ctx.closePath(); ctx.fill();
效果
關(guān)于“Canvas如何制作旋轉(zhuǎn)太極的動畫”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
網(wǎng)頁名稱:Canvas如何制作旋轉(zhuǎn)太極的動畫
網(wǎng)站URL:http://muchs.cn/article48/jcpeep.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站導(dǎo)航、品牌網(wǎng)站制作、企業(yè)網(wǎng)站制作、網(wǎng)站改版、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)