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 { get }
  • Whether or not the size is inverted.

    Declaration

    Swift

    public var isSizeInverted: Bool { get }
  • 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 given Orientation.

    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 point relative to the inputRect.

    Declaration

    Swift

    public func normalize(_ point: CGPoint) -> CGPoint

    Parameters

    point

    The point that should be normalized.

    Return Value

    The normalized point.

  • Normalizes a given vector relative to the inputRect.

    Declaration

    Swift

    public func normalize(_ vector: CGVector) -> CGVector

    Parameters

    vector

    The vector that should be normalized.

    Return Value

    The normalized vector.

  • Normalizes a given size relative to the inputRect.

    Declaration

    Swift

    public func normalize(_ size: CGSize) -> CGSize

    Parameters

    size

    The size that should be normalized.

    Return Value

    The normalized size.

  • Normalizes a given rect relative to 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 point relative to the inputRect.

    Declaration

    Swift

    public func denormalize(_ point: CGPoint) -> CGPoint

    Parameters

    point

    The point that should be denormalized.

    Return Value

    The denormalized point.

  • Denormalizes the given rect relative to the inputRect.

    Declaration

    Swift

    public func denormalize(_ rect: CGRect) -> CGRect

    Parameters

    rect

    The rect that should be denormalized.

    Return Value

    The denormalized rect.