Raphael.js:绘制一个带有边缘边框和填充颜色的圆圈

Ila*_*Ila 5 javascript svg raphael

用数字绘制SVG令人困惑但非常非常有用.通过修改其他人的例子,我有一个Raphael.js函数需要60秒才能在圆圈周围绘制一条粗绿线,文本位于圆圈的中心.这里是JSFiddle形式,容器Div上有黑色背景,表示圆圈上当前没有背景颜色:

http://jsfiddle.net/8NZfU/1/

这是JS:

//60s circular timer
function timer60s() {

var archtype = Raphael("canvas60s", 200, 200);
var set = archtype.set();

function drawCircle() {
  var archtype = Raphael("canvas60s", 200, 200);
  archtype.customAttributes.arc = function (xloc, yloc, value, total, R) {
    var alpha = 360 / total * value,
        a = (90 - alpha) * Math.PI / 180,
        x = xloc + R * Math.cos(a),
        y = yloc - R * Math.sin(a),
        path;
    if (total == value) {
      path = [
          ["M", xloc, yloc - R],
          ["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
      ];
    } else {
      path = [
          ["M", xloc, yloc - R],
          ["A", R, R, 0, +(alpha > 180), 1, x, y]
      ];
    }
    return {
       path: path
    };
  };


  var my_arc = archtype.path().attr({
      "stroke": "#339933",
      "stroke-width": 10,
      arc: [100, 100, 0, 100, 50]
  });



  my_arc.animate({
     arc: [100, 100, 100, 100, 50]
  }, 60000);


} //end drawCircle





    drawCircle();

  } // end timer60s

  timer60s();
Run Code Online (Sandbox Code Playgroud)

我想要的是在绘制弧的位置内的整个圆上创建白色背景的效果.我还想在弧的任一侧添加静态的薄绿色边框,这样看起来弧线在线之间缓慢填充.

我没有成功在CSS或Raphael中绘制这个背景+边框 - 任何人都可以根据我的JSFiddle推荐一种可行的方法吗?

Ron*_*den 2

我不确定,但是你能画第二个圆圈吗?

像这样: http: //jsfiddle.net/5knjn/

archtype.circle(100, 100, 50).attr({
    "fill": "#fff",
    "stroke": "#fff",
    "stroke-width": "10"
});
Run Code Online (Sandbox Code Playgroud)

我不明白这部分:

I also want to add static thin green borders to either side of the arc, so that it appears that the arc is slowly filling in between the lines.

所以我想出了:) http://jsfiddle.net/5knjn/1/

我也不喜欢您在画布中输入文本的方式。

你可以使用Raphael.text()

包含文本: http: //jsfiddle.net/5knjn/2/