From bb36ee6d9c58e3a51cffd8b1e0ff7585621d2939 Mon Sep 17 00:00:00 2001 From: taipaise Date: Tue, 12 Nov 2024 21:46:01 +0900 Subject: [PATCH] =?UTF-8?q?feature:=20=EA=B7=B8=EB=A6=BC=20=EC=98=A4?= =?UTF-8?q?=EB=B8=8C=EC=A0=9D=ED=8A=B8=20=EC=84=A4=EA=B3=84(#58)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Domain/Domain.xcodeproj/project.pbxproj | 4 ++ .../Domain/Sources/Entity/DrawingObject.swift | 49 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Domain/Domain/Sources/Entity/DrawingObject.swift diff --git a/Domain/Domain.xcodeproj/project.pbxproj b/Domain/Domain.xcodeproj/project.pbxproj index 265dfaf..ed69bb1 100644 --- a/Domain/Domain.xcodeproj/project.pbxproj +++ b/Domain/Domain.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 00683D692CE37F2F000D28E4 /* DrawingObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00683D682CE37F2F000D28E4 /* DrawingObject.swift */; }; 0080E85B2CE19EBD0095B958 /* DomainStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8582CE19EBD0095B958 /* DomainStruct.swift */; }; 0080E8BB2CE2ECD80095B958 /* WhiteboardObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8BA2CE2ECC60095B958 /* WhiteboardObject.swift */; }; 0080E8CE2CE4463B0095B958 /* WhiteboardObjectRepositoryInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0080E8CD2CE4462E0095B958 /* WhiteboardObjectRepositoryInterface.swift */; }; @@ -29,6 +30,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 00683D682CE37F2F000D28E4 /* DrawingObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawingObject.swift; sourceTree = ""; }; 0080E8582CE19EBD0095B958 /* DomainStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainStruct.swift; sourceTree = ""; }; 0080E8BA2CE2ECC60095B958 /* WhiteboardObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObject.swift; sourceTree = ""; }; 0080E8CD2CE4462E0095B958 /* WhiteboardObjectRepositoryInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObjectRepositoryInterface.swift; sourceTree = ""; }; @@ -70,6 +72,7 @@ isa = PBXGroup; children = ( 0080E8BA2CE2ECC60095B958 /* WhiteboardObject.swift */, + 00683D682CE37F2F000D28E4 /* DrawingObject.swift */, ); path = Entity; sourceTree = ""; @@ -225,6 +228,7 @@ 0080E8CE2CE4463B0095B958 /* WhiteboardObjectRepositoryInterface.swift in Sources */, 0080E85B2CE19EBD0095B958 /* DomainStruct.swift in Sources */, 0080E8BB2CE2ECD80095B958 /* WhiteboardObject.swift in Sources */, + 00683D692CE37F2F000D28E4 /* DrawingObject.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Domain/Domain/Sources/Entity/DrawingObject.swift b/Domain/Domain/Sources/Entity/DrawingObject.swift new file mode 100644 index 0000000..48897d5 --- /dev/null +++ b/Domain/Domain/Sources/Entity/DrawingObject.swift @@ -0,0 +1,49 @@ +// +// DrawingObject.swift +// Domain +// +// Created by 이동현 on 11/12/24. +// +import Foundation + +public class DrawingObject: WhiteboardObject { + public private(set) var points: [CGPoint] + + public init( + id: UUID, + position: CGPoint, + size: CGSize, + points: [CGPoint] + ) { + self.points = points + super.init( + id: id, + position: position, + size: size) + } + + public convenience override init( + id: UUID, + position: CGPoint, + size: CGSize + ) { + self.init( + id: id, + position: position, + size: size, + points: []) + } + + public func addPoint(point: CGPoint) { + points.append(point) + } + + //TODO: - 화이트보드 오브젝트 수정 구현 시 고도화 + public func move(by translation: CGPoint) { + points = points.map { + let newOriginX = $0.x + translation.x + let newOriginY = $0.y + translation.y + return CGPoint(x: newOriginX, y: newOriginY) + } + } +}