日本精品无码一区二区三区久久久,99久久国产综合色婷婷,7777精品伊人久久久大香线蕉,人人妻人人澡人人爽人人dvd,久久精品中文字幕

使用html5的fillRect和setTransform畫立方體

開發(fā)技術(shù) 2015/6/19

原理分析:
畫三個長方形,頂部長方形和側(cè)面長方形變形,然后將三個長方形移到合適的位置,這樣一個長方體就完成了

代碼如下:
<div style="width: 600px; margin: 0 auto; margin-top: 30px;">
<canvas id="myCanvas" width="600" height="350" style="border:1px solid #d3d3d3;">
    你的瀏覽器不支持canvas....
</canvas></div>
<script>
    var canvas = document.getElementById('myCanvas');
    var ctx = canvas.getContext("2d");
    ctx.beginPath();
    ctx.fillStyle="#0000ff";
    ctx.fillRect(120,100,150,200);
    ctx.closePath();

    ctx.beginPath();
    ctx.setTransform(1,0,-0.5,0.5,50,50);
    ctx.fillStyle="red";
    ctx.fillRect(120,0,150,100);
    ctx.closePath();

    ctx.beginPath();
    ctx.setTransform(0,1,-0.5,0.5,320,-70);
    ctx.fillStyle="green";
    ctx.fillRect(120,0,200,100);
    ctx.closePath();

</script>

中國· 上海

谷谷二維碼
添加微信咨詢

CopyRight?2009-2019 上海谷谷網(wǎng)絡(luò)科技有限公司 All Rights Reserved. 滬ICP備11022482號-8  

關(guān)于我們 | 聯(lián)系我們