就像我们在CSS中进行position: relative;
一样,我需要相对于父级Group
定位所有新创建的项目。这是我期望得到的:
...具有以下代码:
var path = new Path([50, 0], [50, 100]);
var path2 = new Path([0, 50], [100, 50]);
// cross center at [50, 50]
var center = [100, 100]
var group = new Group({
children: [path, path2],
strokeColor: 'black'
});
// It's important to arrange the position
// right after creating the group
group.translate([50, 50])
new Path.Circle({
center: center,
radius: 5,
fillColor: 'red'
})
new Path.Rectangle({
from: [10, 10],
to: [40, 40],
strokeColor: 'black',
parent: group
})
但是,what I actually get is如下:
如何使新创建的项目相对于其父组定位?
注意:为了获取“所需”屏幕截图,我需要在插入矩形后
.translate()
group
:Sketch
答案 0 :(得分:0)
事实证明,它受applyMatrix: false
参数Sketch
var group = new Group({
children: [path, path2],
strokeColor: 'black',
applyMatrix: false,
});
group.translate([50, 50])