国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > HTML5 > 正文

Canvas制作旋轉(zhuǎn)的太極的示例

2024-09-05 07:22:24
字體:
供稿:網(wǎng)友

前言

好久沒動canvas了,今下午突然想回顧一下,就寫了個旋轉(zhuǎn)的太極,哈哈,蠻好玩的,在這里就將自己寫的過程展示出來,旋轉(zhuǎn)使用的css實(shí)現(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-bigctx.beginPath();ctx.fillStyle = "#000";ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,false);ctx.closePath();ctx.fill();// right-white-bigctx.beginPath();ctx.fillStyle = "#fff";ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,true);ctx.closePath();ctx.fill();// top-black-middlectx.beginPath();ctx.fillStyle = "#000";ctx.arc(250,150,100,Math.PI/2,Math.PI*1.5,true);ctx.closePath();ctx.fill();// bottom-white-middlectx.beginPath();ctx.fillStyle = "#fff";ctx.arc(250,350,100,Math.PI/2,Math.PI*1.5,false);ctx.closePath();ctx.fill();// top-white-smallctx.beginPath();ctx.fillStyle = "#fff";ctx.arc(250,150,25,0,Math.PI*2);ctx.closePath();ctx.fill();// bottom-black-smallctx.beginPath();ctx.fillStyle = "#000";ctx.arc(250,350,25,0,Math.PI*2);ctx.closePath();ctx.fill();

效果

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 建德市| 钦州市| 万载县| 新晃| 遂川县| 淮安市| 西乌珠穆沁旗| 台湾省| 永吉县| 阿尔山市| 永济市| 体育| 雷山县| 焉耆| 浪卡子县| 乐亭县| 芜湖县| 乌恰县| 柳州市| 政和县| 河南省| 鹤峰县| 易门县| 崇阳县| 鹤山市| 大足县| 佛教| 乳山市| 苍山县| 托克逊县| 资兴市| 健康| 长汀县| 安平县| 枣庄市| 九江县| 广宗县| 邳州市| 共和县| 砚山县| 正蓝旗|