diff --git a/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift b/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift index 583b5ba6fc..7a5e065ac1 100644 --- a/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift +++ b/submodules/DrawingUI/Sources/DrawingEntitySnapTool.swift @@ -308,7 +308,7 @@ class DrawingEntitySnapTool { func maybeSkipFromStart(entityView: DrawingEntityView, rotation: CGFloat) { self.rotationState = nil - let snapDelta: CGFloat = 0.25 + let snapDelta: CGFloat = 0.01 for snapRotation in self.snapRotations { let snapRotation = snapRotation * .pi if rotation > snapRotation - snapDelta && rotation < snapRotation + snapDelta { @@ -318,7 +318,7 @@ class DrawingEntitySnapTool { } } - func update(entityView: DrawingEntityView, velocity: CGFloat, delta: CGFloat, updatedRotation: CGFloat) -> CGFloat { + func update(entityView: DrawingEntityView, velocity: CGFloat, delta: CGFloat, updatedRotation: CGFloat, skipMultiplier: CGFloat = 1.0) -> CGFloat { var updatedRotation = updatedRotation if updatedRotation < 0.0 { updatedRotation = 2.0 * .pi + updatedRotation @@ -332,7 +332,7 @@ class DrawingEntitySnapTool { let snapDelta: CGFloat = 0.01 let snapVelocity: CGFloat = snapDelta * 35.0 - let snapSkipRotation: CGFloat = snapDelta * 40.0 + let snapSkipRotation: CGFloat = snapDelta * 45.0 * skipMultiplier if abs(velocity) < snapVelocity || self.rotationState?.waitForLeave == true { if let (snapRotation, skipped, waitForLeave) = self.rotationState { diff --git a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift index 7e8528c3d3..1d60e7a1ce 100644 --- a/submodules/DrawingUI/Sources/DrawingStickerEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingStickerEntity.swift @@ -547,9 +547,12 @@ final class DrawingStickerEntititySelectionView: DrawingEntitySelectionView { } else { newAngle = atan2(parentLocation.y - self.center.y, parentLocation.x - self.center.x) } - - // let delta = newAngle - updatedRotation - updatedRotation = newAngle// self.snapTool.update(entityView: entityView, velocity: 0.0, delta: delta, updatedRotation: newAngle) + var delta = newAngle - updatedRotation + if delta < -.pi { + delta = 2.0 * .pi + delta + } + let velocityValue = sqrt(velocity.x * velocity.x + velocity.y * velocity.y) / 1000.0 + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocityValue, delta: delta, updatedRotation: newAngle, skipMultiplier: 1.0) } else if self.currentHandle === self.layer { updatedPosition.x += delta.x updatedPosition.y += delta.y diff --git a/submodules/DrawingUI/Sources/DrawingTextEntity.swift b/submodules/DrawingUI/Sources/DrawingTextEntity.swift index 0d96a6b946..205ecc7a85 100644 --- a/submodules/DrawingUI/Sources/DrawingTextEntity.swift +++ b/submodules/DrawingUI/Sources/DrawingTextEntity.swift @@ -869,9 +869,12 @@ final class DrawingTextEntititySelectionView: DrawingEntitySelectionView { } else { newAngle = atan2(parentLocation.y - self.center.y, parentLocation.x - self.center.x) } - - //let delta = newAngle - updatedRotation - updatedRotation = newAngle //" self.snapTool.update(entityView: entityView, velocity: 0.0, delta: delta, updatedRotation: newAngle) + var delta = newAngle - updatedRotation + if delta < -.pi { + delta = 2.0 * .pi + delta + } + let velocityValue = sqrt(velocity.x * velocity.x + velocity.y * velocity.y) / 1000.0 + updatedRotation = self.snapTool.update(entityView: entityView, velocity: velocityValue, delta: delta, updatedRotation: newAngle, skipMultiplier: 1.0) } else if self.currentHandle === self.layer { updatedPosition.x += delta.x updatedPosition.y += delta.y