Skip to content

Commit

Permalink
feature: 그림 오브젝트 설계(#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
taipaise committed Nov 14, 2024
1 parent e1cf0ca commit bb36ee6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Domain/Domain.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -29,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
00683D682CE37F2F000D28E4 /* DrawingObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DrawingObject.swift; sourceTree = "<group>"; };
0080E8582CE19EBD0095B958 /* DomainStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DomainStruct.swift; sourceTree = "<group>"; };
0080E8BA2CE2ECC60095B958 /* WhiteboardObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObject.swift; sourceTree = "<group>"; };
0080E8CD2CE4462E0095B958 /* WhiteboardObjectRepositoryInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WhiteboardObjectRepositoryInterface.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -70,6 +72,7 @@
isa = PBXGroup;
children = (
0080E8BA2CE2ECC60095B958 /* WhiteboardObject.swift */,
00683D682CE37F2F000D28E4 /* DrawingObject.swift */,
);
path = Entity;
sourceTree = "<group>";
Expand Down Expand Up @@ -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;
};
Expand Down
49 changes: 49 additions & 0 deletions Domain/Domain/Sources/Entity/DrawingObject.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
}

0 comments on commit bb36ee6

Please sign in to comment.