国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宝鸡市| 珠海市| 淮滨县| 大洼县| 安庆市| 平和县| 南召县| 琼海市| 涡阳县| 苏尼特左旗| 商城县| 兴国县| 孝义市| 巴青县| 海盐县| 东乡族自治县| 醴陵市| 博湖县| 疏勒县| 武胜县| 南涧| 长汀县| 白玉县| 三穗县| 突泉县| 金华市| 和平区| 天祝| 乐山市| 阳朔县| 铁岭县| 米林县| 汕头市| 花莲县| 东方市| 屯昌县| 云安县| 安仁县| 香河县| 沙河市| 宁陕县|