我需要动画一个点(在Paper.js中称为分段)的多边形,旋转它在一个圆与原点在原来的多边形点。见下图:

我试着用下面的代码来做:
// Draw the polygon
var polygon = new Path.RegularPolygon({
center: [100, 100],
sides: 8,
radius: 80,
});
// Animate
view.onFrame = function (event) {
var offset = new Point(Math.cos(event.time*2), Math.sin(event.time*2));
polygon.firstSegment.point = polygon.firstSegment.point.add(offset);
};但我有两个问题:
在这里,查看它的全部代码是:
https://codepen.io/anon/pen/xezQpb
有人能帮忙吗?谢谢
发布于 2019-04-22 08:41:42
问题是,在每一帧中,你指的是第一段的位置,它在前一帧中移动了一点,所以偏移量之和。
相反,只需在开始时记录中心并与其相抵:
var center = polygon.firstSegment.point.clone();
[...]
polygon.firstSegment.point = center.add(offset);https://stackoverflow.com/questions/55784596
复制相似问题