diff --git a/Sources/Geometry/Extensions/CGPathExt.swift b/Sources/Geometry/Extensions/CGPathExt.swift index 126de3c..19549a9 100644 --- a/Sources/Geometry/Extensions/CGPathExt.swift +++ b/Sources/Geometry/Extensions/CGPathExt.swift @@ -82,16 +82,6 @@ extension CGPath { // MARK: - Helper Functions -/// Limits the precision of a CGFloat to a specified number of decimal places. -/// - Parameters: -/// - value: The CGFloat value to limit. -/// - places: The number of decimal places to retain. -/// - Returns: A CGFloat rounded to the specified number of decimal places. -private func limitPrecision(_ value: CGFloat, toDecimalPlaces places: Int) -> CGFloat { - let multiplier = pow(10.0, CGFloat(places)) - return (value * multiplier).rounded() / multiplier -} - /// Creates a CGVector from two CGPoints. /// - Parameters: /// - from: The starting CGPoint. diff --git a/Sources/Geometry/SwiftUI View Modifiers/FrameListModifier.swift b/Sources/Geometry/SwiftUI View Modifiers/FrameListModifier.swift index 3595b5c..a8a77a8 100644 --- a/Sources/Geometry/SwiftUI View Modifiers/FrameListModifier.swift +++ b/Sources/Geometry/SwiftUI View Modifiers/FrameListModifier.swift @@ -37,15 +37,26 @@ private enum FrameListModifier: ViewModifier where ID: Hashable { } extension View { - func frames(_ value: Binding<[ID: CGRect]>) -> some View where ID: Hashable { + + /// A modifier which observes changes to view frames with corresponding IDs + /// - Parameter value: a binding to a dictionary of IDs to frame rectangle + /// - Returns: a View + public func frames(_ value: Binding<[ID: CGRect]>) -> some View where ID: Hashable { readFrames { value.wrappedValue = $0 } } - func writeFrame(id: ID, coordinates: CoordinateSpace) -> some View where ID: Hashable { + /// A modifier which writes changes to the current view's frame with corresponding `id` + /// - Parameter id: the current view's corresponding ID + /// - Parameter coordinates: the coordinate space in which the frame is expressed + /// - Returns: a View + public func writeFrame(id: ID, coordinates: CoordinateSpace) -> some View where ID: Hashable { self.modifier(FrameListModifier.writer(id: id, coordinates: coordinates)) } - func readFrames(onChange: @escaping ([ID: CGRect])-> ()) -> some View where ID: Hashable { + /// A modifier which reads changes to view frames with corresponding IDs + /// - Parameter value: a binding to a dictionary of IDs to frame rectangle + /// - Returns: a View + public func readFrames(onChange: @escaping ([ID: CGRect])-> ()) -> some View where ID: Hashable { self.modifier(FrameListModifier.reader(onChange: onChange)) } } diff --git a/Sources/Geometry/SwiftUI View Modifiers/FrameModifier.swift b/Sources/Geometry/SwiftUI View Modifiers/FrameModifier.swift index bea4fbc..d99d53d 100644 --- a/Sources/Geometry/SwiftUI View Modifiers/FrameModifier.swift +++ b/Sources/Geometry/SwiftUI View Modifiers/FrameModifier.swift @@ -36,7 +36,7 @@ private struct FrameModifier: ViewModifier { extension View { - /// An extension whose `value` tracks the enclosed view's bounding rectangle in `coordinates` + /// A modifier whose `value` tracks the enclosed view's bounding rectangle in `coordinates` /// - Parameters: /// - value: a `CGRect` binding /// - coordinates: a coordinate space @@ -47,7 +47,7 @@ extension View { }) } - /// An extension whose `value` tracks the enclosed view's size in `coordinates` + /// A modifier whose `value` tracks the enclosed view's size in `coordinates` /// - Parameters: /// - value: a `CGSize` binding /// - coordinates: a coordinate space @@ -58,7 +58,7 @@ extension View { }) } - /// An extension whose `value` tracks the enclosed view's origin in `coordinates` + /// A modifier whose `value` tracks the enclosed view's origin in `coordinates` /// - Parameters: /// - value: a `CGPoint` binding /// - coordinates: a coordinate space