Anchor2D

public struct Anchor2D : Hashable

Represents a point in a rectangle as a ratio of this rectangle’s width and height.

  • Defines the x axis where the left is 0, the right is 1 and the middle is 0.5. The default value is 0.5.

    Declaration

    Swift

    public var horizontal: Double
  • Defines the y axis where the top is 0, the bottom is 1 and the middle is 0.5. The default value is 0.5.

    Declaration

    Swift

    public var vertical: Double
  • Creates a new instance of an Anchor2D with the default parameters

    Declaration

    Swift

    public init()
  • Creates a new instance of an Anchor2D.

    Declaration

    Swift

    public init(horizontal: Double, vertical: Double)

    Parameters

    horizontal

    Defines the x axis where the left is 0, the right is 1 and the middle is 0.5.

    vertical

    Defines the y axis where the top is 0, the bottom is 1 and the middle is 0.5.

  • Returns an anchor positioned at the center.

    Declaration

    Swift

    public static func center() -> Anchor2D

    Return Value

    An Anchor2D at (0.5, 0.5).

  • Returns an anchor positioned at the top center.

    Declaration

    Swift

    public static func top() -> Anchor2D

    Return Value

    An Anchor2D at (0.5, 0.0).

  • Returns an anchor positioned at the top right.

    Declaration

    Swift

    public static func topRight() -> Anchor2D

    Return Value

    An Anchor2D at (1.0, 0.0).

  • Returns an anchor positioned at the right center.

    Declaration

    Swift

    public static func right() -> Anchor2D

    Return Value

    An Anchor2D at (1.0, 0.5).

  • Returns an anchor positioned at the bottom right.

    Declaration

    Swift

    public static func bottomRight() -> Anchor2D

    Return Value

    An Anchor2D at (1.0, 1.0).

  • Returns an anchor positioned at the bottom center.

    Declaration

    Swift

    public static func bottom() -> Anchor2D

    Return Value

    An Anchor2D at (0.5, 1.0).

  • Returns an anchor positioned at the bottom left.

    Declaration

    Swift

    public static func bottomLeft() -> Anchor2D

    Return Value

    An Anchor2D at (0.0, 1.0).

  • Returns an anchor positioned at the left center.

    Declaration

    Swift

    public static func left() -> Anchor2D

    Return Value

    An Anchor2D at (0.0, 0.5).

  • Returns an anchor positioned at the top left.

    Declaration

    Swift

    public static func topLeft() -> Anchor2D

    Return Value

    An Anchor2D at (0.0, 0.0).