mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 16:18:11 +08:00
Remove snap rotate from layerdata (#435)
This commit is contained in:
committed by
Keavon Chambers
parent
9afa29097b
commit
c1560dbec3
@@ -1,4 +1,3 @@
|
||||
use crate::consts::VIEWPORT_ROTATE_SNAP_INTERVAL;
|
||||
use glam::{DAffine2, DVec2};
|
||||
use graphene::layers::{style::ViewMode, BlendMode, Layer, LayerData as DocumentLayerData, LayerDataType};
|
||||
use graphene::LayerId;
|
||||
@@ -12,7 +11,6 @@ pub struct LayerData {
|
||||
pub expanded: bool,
|
||||
pub translation: DVec2,
|
||||
pub rotation: f64,
|
||||
pub snap_rotate: bool,
|
||||
pub scale: f64,
|
||||
}
|
||||
|
||||
@@ -23,25 +21,15 @@ impl LayerData {
|
||||
expanded,
|
||||
translation: DVec2::ZERO,
|
||||
rotation: 0.,
|
||||
snap_rotate: false,
|
||||
scale: 1.,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn snapped_angle(&self) -> f64 {
|
||||
let increment_radians: f64 = VIEWPORT_ROTATE_SNAP_INTERVAL.to_radians();
|
||||
if self.snap_rotate {
|
||||
(self.rotation / increment_radians).round() * increment_radians
|
||||
} else {
|
||||
self.rotation
|
||||
}
|
||||
}
|
||||
|
||||
pub fn calculate_offset_transform(&self, offset: DVec2) -> DAffine2 {
|
||||
pub fn calculate_offset_transform(&self, offset: DVec2, snapped_angle: f64) -> DAffine2 {
|
||||
// TODO: replace with DAffine2::from_scale_angle_translation and fix the errors
|
||||
let offset_transform = DAffine2::from_translation(offset);
|
||||
let scale_transform = DAffine2::from_scale(DVec2::new(self.scale, self.scale));
|
||||
let angle_transform = DAffine2::from_angle(self.snapped_angle());
|
||||
let angle_transform = DAffine2::from_angle(snapped_angle);
|
||||
let translation_transform = DAffine2::from_translation(self.translation);
|
||||
scale_transform * offset_transform * angle_transform * translation_transform
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user