mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-31 15:37:01 +00:00
Improve drawing entities snapping
This commit is contained in:
parent
3e4cf69560
commit
f83b6e7c7a
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user