【问题标题】:draw spiral circles in canvas在画布上绘制螺旋圈
【发布时间】:2013-03-08 02:22:24
【问题描述】:

我想在canvas 中绘制这种螺旋图案我正在使用下面的代码 需要您的帮助以进一步绘制圆圈。

 // get the canvas element using the DOM
 var canvas = document.getElementById('circlecanvas');
 // Make sure we don't execute when canvas isn't supported
 if (canvas.getContext){
    // use getContext to use the canvas for drawing
    var ctx = canvas.getContext('2d');
    // Draw shapes
    ctx.beginPath();
    //context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
    for (i=0;i<9;i++){
        ctx.arc(50, 50, 50, i, Math.PI * 2, false);
        ctx.fill();
    }
}  

【问题讨论】:

  • 您遇到的问题是什么?什么都没发生?有错误吗?等等?
  • 只有一个圆圈在画.. 但想要看起来像图案

标签: html html5-canvas


【解决方案1】:

我认为你需要的是一个螺旋... 我正在发布伪代码以在下面绘制阿基米德螺旋:- NB-角度是一个变量..您可以相应地调整...

for (i=0; i< 720; i++) {
  angle = 0.1 * i;
  x=(1+angle)*Math.cos(angle);
  y=(1+angle)*Math.sin(angle);
  drawlineTo(x, y);
}

【讨论】:

猜你喜欢
  • 2011-10-13
  • 1970-01-01
  • 2023-03-28
  • 1970-01-01
  • 2015-11-03
  • 1970-01-01
  • 2019-11-20
  • 1970-01-01
  • 2011-03-11
相关资源
最近更新 更多