0

我怎样才能从组中只删除特定的孩子。这是我的代码。谁能帮忙。

    <script type="text/paperscript" canvas="canvas">

var path = new Path.Circle(new Point(80, 50), 35);
var secondPath = new Path.Circle(new Point(180, 50), 35);


var group = new Group();

group.addChild(path);
group.addChild(secondPath);


group.fillColor = 'green';


group.removeChildren();
    </script>

如何删除路径或第二条路径。

4

3 回答 3

2

只需给路径命名: http: //paperjs.org/reference/path

var path = new Path.Circle({
    center: [80, 50],
    radius: 35
});
// Set the name of the path:
path.name = 'example';

// Create a group and add path to it as a child:
var group = new Group();
group.addChild(path);

// The path can be accessed by name:
group.children['example'].fillColor = 'red';
于 2013-06-30T21:03:26.257 回答
0

参考http://paperjs.org/reference/group/#group

路径名.remove()

例子

secondpath.remove()

于 2013-09-03T11:23:04.550 回答
0

我查看了文档,您必须指定索引或索引 from - index to。所以如果你想要最后一个:

group.removeChildren(group.children.length - 1);

或首先

group.removeChildren(0);

于 2013-06-07T06:28:59.767 回答