Line

public class Line: Polygon

Line is a is a concrete subclass of Polygon that contains only two points.

This subclass overrides the points variable so that it can only ever have 2 points, and also has an endPoints variable that allows the user to edit either end of the line (animatable).

  • The end points the receiver’s line. Animatable.

    Assigning a tuple of Point values to this object will cause the receiver to update itself.

    Declaration

    Swift

    public var endPoints: (Point, Point) = (Point(), Point(100, 0))

    Return Value

    A tuple (2) of C4Points that make up the the begin and end points of the line.

  • The center point (top-left) of the receiver’s frame. Animatable.

    Declaration

    Swift

    public override var center: Point

    Return Value

    A Point, the receiver’s center.

  • The origin point (top-left) of the receiver’s frame. Animatable.

    Declaration

    Swift

    public override var origin: Point

    Return Value

    A Point, the receiver’s origin.

  • The points that make up the line. Animatable.

    Assigning an array of Point values to this object will cause the receiver to update itself.

    Declaration

    Swift

    public override var points: [Point]

    Return Value

    A Point array of 2 points.

  • Initializes a new Polygon using the specified array of points.

    Protects against trying to create a polygon with only 1 point (i.e. requires 2 points). Trims point array if count > 2.

    let a = Point(100,100)
    let b = Point(200,200)
    
    let l = Line([a,b])
    

    Declaration

    Swift

    public override init(_ points: [Point])

    Parameters

    points

    An array of Point structs.

  • Initializes a new Line using the specified tuple of points.

    let a = Point(100,100)
    let b = Point(200,200)
    
    let l = Line((a,b))
    

    Declaration

    Swift

    public init(_ points: (Point, Point))

    Parameters

    points

    A tuple of Point structs.

  • Initializes a new Line using two specified points.

    let a = Point(100,100)
    let b = Point(200,200)
    
    let l = Line(begin: a, end: b)
    

    Declaration

    Swift

    public convenience init(begin: Point, end: Point)

    Parameters

    begin

    The start point of the line.

    end

    The end point of the line.

  • Initializes a new Polygon from data in a given unarchiver. - parameter coder: An unarchiver object.

    Declaration

    Swift

    required public init(coder: NSCoder)

    Parameters

    coder

    An unarchiver object.