Skip to content

Commit

Permalink
Add int inits to point/rect (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
finnvoor authored Aug 11, 2024
1 parent c0fbddc commit 778178f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/PlaydateKit/Geometry/Point.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ public struct Point: Equatable {
self.y = y
}

@_disfavoredOverload public init(x: CInt, y: CInt) {
self.x = Float(x)
self.y = Float(y)
}

// MARK: Public

/// The point with location (0,0).
Expand Down
7 changes: 7 additions & 0 deletions Sources/PlaydateKit/Geometry/Rect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ public struct Rect: Equatable {
self.height = height
}

@_disfavoredOverload public init(x: CInt, y: CInt, width: CInt, height: CInt) {
self.x = Float(x)
self.y = Float(y)
self.width = Float(width)
self.height = Float(height)
}

public init(origin: Point, width: Float, height: Float) {
x = origin.x
y = origin.y
Expand Down

0 comments on commit 778178f

Please sign in to comment.