ImageGeometry
public struct ImageGeometry: CustomStringConvertible
Handles the geometry of an image and provides helpers to easily rotate or flip an image.
-
The rectangle of the input image.
Declaration
Swift
public let inputRect: CGRect
-
The currently applied orientation.
Declaration
Swift
public var appliedOrientation: Orientation
-
The currently applied transform.
Declaration
Swift
public var appliedTransform: CGAffineTransform
-
Whether or not the size is inverted.
Declaration
Swift
public var isSizeInverted: Bool
-
Creates an
ImageGeometry
using the given input size.Declaration
Swift
public init(inputSize: CGSize)
Parameters
inputSize
The input size of the image.
Return Value
An image geometry.
-
Creates an
ImageGeometry
using the given input size and the given initial orientation.Declaration
Swift
public init(inputSize: CGSize, initialOrientation: Orientation)
Parameters
inputSize
The input size of the image.
initialOrientation
The initial orientation to use.
Return Value
An image geometry.
-
Creates a
CGAffineTransform
from a givenOrientation
.Declaration
Swift
public func transform(from orientation: Orientation) -> CGAffineTransform
Parameters
orientation
The
Orientation
to get the transform for.Return Value
A
CGAffineTransform
, that when applied to a view rotates it to the same orientation as the passed orientation. -
Apply a vertical flip to the image’s geometry.
Declaration
Swift
public mutating func flipVertically()
-
Apply a horizontal flip to the image’s geometry.
Declaration
Swift
public mutating func flipHorizontally()
-
Rotate the image’s geometry clockwise by 90 degrees.
Declaration
Swift
public mutating func rotateClockwise()
-
Rotate the image’s geometry counter clockwise by 90 degrees.
Declaration
Swift
public mutating func rotateCounterClockwise()
-
Directly applies a given orientation to the image’s geometry.
Declaration
Swift
public mutating func apply(_ orientation: Orientation)
Parameters
orientation
The orientation to apply.
-
Normalizes a given denormalized rect using the
inputRect
.Declaration
Swift
public func normalize(_ rect: CGRect) -> CGRect
Parameters
rect
The rect that should be normalized.
Return Value
The normalized rect.
-
Denormalizes the given normalized rect using the
inputRect
.Declaration
Swift
public func denormalize(_ rect: CGRect) -> CGRect
Parameters
rect
The rect that should be denormalized.
Return Value
The denormalized rect.