feat: update canvas zoom scale

This commit is contained in:
dscyrescotti
2024-05-15 13:43:22 +07:00
parent c0c039ebfe
commit 3ad8075a28
5 changed files with 6 additions and 8 deletions
+1 -3
View File
@@ -18,7 +18,7 @@ final class Canvas: ObservableObject, Identifiable, @unchecked Sendable {
var graphicContext = GraphicContext() var graphicContext = GraphicContext()
let viewPortContext = ViewPortContext() let viewPortContext = ViewPortContext()
let maximumZoomScale: CGFloat = 30 let maximumZoomScale: CGFloat = 35
let minimumZoomScale: CGFloat = 5 let minimumZoomScale: CGFloat = 5
let defaultZoomScale: CGFloat = 20 let defaultZoomScale: CGFloat = 20
@@ -48,7 +48,6 @@ extension Canvas {
func load() { func load() {
withPersistence(\.backgroundContext) { [weak self, canvasID, bounds] context in withPersistence(\.backgroundContext) { [weak self, canvasID, bounds] context in
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
NSLog(Date().formatted(.dateTime.minute().second().secondFraction(.fractional(2))))
self?.state = .loading self?.state = .loading
} }
guard let canvas = context.object(with: canvasID) as? CanvasObject else { guard let canvas = context.object(with: canvasID) as? CanvasObject else {
@@ -59,7 +58,6 @@ extension Canvas {
self?.graphicContext.loadStrokes(bounds) self?.graphicContext.loadStrokes(bounds)
context.refresh(canvas, mergeChanges: false) context.refresh(canvas, mergeChanges: false)
DispatchQueue.main.async { [weak self] in DispatchQueue.main.async { [weak self] in
NSLog(Date().formatted(.dateTime.minute().second().secondFraction(.fractional(2))))
self?.state = .loaded self?.state = .loaded
} }
} }
@@ -12,7 +12,7 @@ struct EraserPenStyle: PenStyle {
var textureName: String = "point-texture" var textureName: String = "point-texture"
var thinkness: (min: CGFloat, max: CGFloat) = (1, 120) var thinkness: (min: CGFloat, max: CGFloat) = (0.5, 120)
var color: [CGFloat] = [1, 1, 1, 0] var color: [CGFloat] = [1, 1, 1, 0]
@@ -12,7 +12,7 @@ struct MarkerPenStyle: PenStyle {
var textureName: String = "point-texture" var textureName: String = "point-texture"
var thinkness: (min: CGFloat, max: CGFloat) = (1, 120) var thinkness: (min: CGFloat, max: CGFloat) = (0.5, 120)
var color: [CGFloat] = [1, 0.38, 0.38, 1] var color: [CGFloat] = [1, 0.38, 0.38, 1]
@@ -32,7 +32,7 @@ class DrawingView: UIView {
} }
func updateDrawableSize(with size: CGSize) { func updateDrawableSize(with size: CGSize) {
renderView.drawableSize = size.multiply(by: 2.0) renderView.drawableSize = size.multiply(by: 3)
} }
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
+2 -2
View File
@@ -69,8 +69,8 @@ struct MemosView: View {
memoObject.updatedAt = .now memoObject.updatedAt = .now
let canvasObject = CanvasObject(context: managedObjectContext) let canvasObject = CanvasObject(context: managedObjectContext)
canvasObject.width = 4_000 canvasObject.width = 8_000
canvasObject.height = 4_000 canvasObject.height = 8_000
let graphicContextObject = GraphicContextObject(context: managedObjectContext) let graphicContextObject = GraphicContextObject(context: managedObjectContext)
graphicContextObject.strokes = [] graphicContextObject.strokes = []