opencv 按中心点旋转 缩放
def rotate_selection(self,alpha):
center = self.get_selection_center()
for cv in self.selection:
temp_path = np.array(cv['data']) - center
# 2D Rotation matrix
R = np.array([[np.cos(alpha), -np.sin(alpha)],
[np.sin(alpha), np.cos(alpha)]])
new_curve = R[:, None, :].dot(temp_path.T)[:, 0, :].T + center
cv['data'] = new_curve
# print(new_curve)
self.recalc_curve_props()
self.update()
def scale_selection(self,sx,sy):
center = self.get_selection_center()
for cv in self.selection:
temp_path = np.array(cv['data']) - center
# 2D Rotation matrix
R = np.array([[sx, 0],
[0, sy]])
new_curve = R[:, None, :].dot(temp_path.T)[:, 0, :].T + center
cv['data'] = new_curve
self.recalc_curve_props()
self.update()