佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > Canvas制作旋轉(zhuǎn)的太極的示例

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

熱門標簽:智能手機 檢查注冊表項 硅谷的囚徒呼叫中心 百度競價點擊價格的計算公式 使用U盤裝系統(tǒng) 阿里云 網(wǎng)站建設 美圖手機

前言

好久沒動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();

效果

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

標簽:湖北 湘潭 賀州 山南 黃山 懷化 煙臺 通遼

巨人網(wǎng)絡通訊聲明:本文標題《Canvas制作旋轉(zhuǎn)的太極的示例》,本文關鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    英德市| 临漳县| 滨海县| 新乡县| 南岸区| 昌乐县| 永和县| 丹凤县| 庆安县| 无棣县| 西乌珠穆沁旗| 盐城市| 铅山县| 广汉市| 邮箱| 西畴县| 吴堡县| 莒南县| 木兰县| 从化市| 宣武区| 深州市| 普定县| 龙泉市| 平湖市| 绥滨县| 罗山县| 石嘴山市| 宾阳县| 阳原县| 靖州| 新昌县| 称多县| 高碑店市| 文化| 清新县| 乌鲁木齐县| 同江市| 万全县| 平罗县| 五河县|