1

如何使用paper.js绘制圆弧线段

我想绘制如图所示的圆形线段。每个部分都是独立的,稍后将用于交互目的。

在此处输入图像描述

我尝试了类似的东西

//Temporary background circle
var keys = new Path.Circle(view.center, 130);
keys.fillColor = '#F1F1F1';

var home = new Path.Circle(view.center, 50);
home.fillColor = '#ee2a33';

var start = new Point(view.center.x, view.center.y-130);
var through = new Point(view.center.x-125, view.center.y-40);
var to = new Point(view.center.x-130, view.center.y);

var path = new Path.Arc(start, through, to);
path.strokeColor = 'black';
path.fillColor = 'green';

它呈现如下

在此处输入图像描述

4

1 回答 1

6

经过几次尝试,我想出了这个。如果有人出于某种原因需要相同的东西,也许这会有所帮助。

//Creating keys
var arcOne = createSegment('#f1f1f1');
var arcTwo = createSegment('#666666');
var arcThree = createSegment('#333333');
var arcFour = createSegment('#666666');
var arcFive = createSegment('#999999');
var arcSix = createSegment('#000000');

arcTwo.rotate(-60, view.center);
arcThree.rotate(-120, view.center);
arcFour.rotate(60, view.center);
arcFive.rotate(120, view.center);
arcSix.rotate(180, view.center);


//center white
var center = new Path.Circle(view.center, 50);
center.fillColor = '#F1F1F1';

//Create Each segment
function createSegment(fillcolor){
    //Segment One
    var start = new Point(view.center.x, view.center.y-130);
    var through = new Point(view.center.x-90, view.center.y-94);
    var to = new Point(view.center.x-113, view.center.y-64);
    var name = Path.Arc(start, through, to);

    name.add(new Point(view.center.x, view.center.y));
    name.add(new Point(view.center.x, view.center.y-130));
    name.fillColor = fillcolor;
    return name;
}
于 2012-02-25T21:17:29.703 回答