From 778178f00d3f0cdd4040eeca522a88639372851e Mon Sep 17 00:00:00 2001 From: Finn Voorhees Date: Sun, 11 Aug 2024 23:52:25 +0100 Subject: [PATCH] Add int inits to point/rect (#77) --- Sources/PlaydateKit/Geometry/Point.swift | 5 +++++ Sources/PlaydateKit/Geometry/Rect.swift | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Sources/PlaydateKit/Geometry/Point.swift b/Sources/PlaydateKit/Geometry/Point.swift index bbc07bf0..b4c5d748 100644 --- a/Sources/PlaydateKit/Geometry/Point.swift +++ b/Sources/PlaydateKit/Geometry/Point.swift @@ -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). diff --git a/Sources/PlaydateKit/Geometry/Rect.swift b/Sources/PlaydateKit/Geometry/Rect.swift index 9da43955..c066b6d7 100644 --- a/Sources/PlaydateKit/Geometry/Rect.swift +++ b/Sources/PlaydateKit/Geometry/Rect.swift @@ -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