From 6cfe59a50e5a4436a3d8d4a95fb087994c802e44 Mon Sep 17 00:00:00 2001 From: yukiny0811 Date: Fri, 2 Feb 2024 21:48:14 +0900 Subject: [PATCH] cgpoint, cgsize cast shortcuts --- Sources/SimpleSimdSwift/CastShortcuts.swift | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Sources/SimpleSimdSwift/CastShortcuts.swift diff --git a/Sources/SimpleSimdSwift/CastShortcuts.swift b/Sources/SimpleSimdSwift/CastShortcuts.swift new file mode 100644 index 0000000..506cf53 --- /dev/null +++ b/Sources/SimpleSimdSwift/CastShortcuts.swift @@ -0,0 +1,33 @@ +// +// File.swift +// +// +// Created by Yuki Kuwashima on 2024/02/02. +// + +import simd +import CoreGraphics + +public extension CGPoint { + var f2Value: f2 { + f2(Float(self.x), Float(self.y)) + } +} + +public extension f2 { + var cgPoint: CGPoint { + CGPoint(x: CGFloat(x), y: CGFloat(y)) + } +} + +public extension CGSize { + var f2Value: f2 { + f2(Float(self.width), Float(self.height)) + } +} + +public extension f2 { + var cgSize: CGSize { + CGSize(width: CGFloat(x), height: CGFloat(y)) + } +}