-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |