笛卡尔心形函数图像_笛卡尔心形曲线
js繪制canvas圖形
var cr = document.getElementById(“cardioid”);
var W = cr.width/2, H = cr.height/3, R = 150;
var c = cr.getContext(“2d”); var G = 360, g = 0, T = Math.PI*2, t = T/G;
c.save(); c.translate(W, H);c.rotate(-T/4);
//c.fillStyle = “red”;
while(g < G){
c.save();//c.translate(W, H);c.rotate(g*t);c.beginPath();c.arc(0, -R*(1-Math.sin(++g*t)), 13, 0, 360, false);c.closePath();c.fill();c.restore();
}
c.restore(); g = 0;
(function draw(){
if(g < G){ c.save(); c.translate(W, H); c.rotate(-T/4 + g*t);c.fillStyle = “red”;c.beginPath();c.arc(0, -R*(1-Math.sin(++g*t)), 5, 0, 360, false); c.closePath(); c.fill(); c.restore();
} setTimeout(draw, 1);
})();
總結
以上是生活随笔為你收集整理的笛卡尔心形函数图像_笛卡尔心形曲线的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP ABAP实用技巧介绍系列之 XS
- 下一篇: 电脑移动硬盘无法弹出如何解决