Circle

public class Circle
extension Circle: SVGDrawable
extension Circle: CGDrawable
extension Circle: RayTracable
extension Circle: Hashable
extension Circle: Polygon

A circle, with an origin and a radius

  • Radius of the circle

    Declaration

    Swift

    public var radius: Double
  • Center point of the circle

    Declaration

    Swift

    public var center: Vector
  • The diameter of the circle

    Declaration

    Swift

    public var diameter: Double { get }
  • Instantiate a new Circle

    Declaration

    Swift

    public init(center: Vector, radius: Double)

    Parameters

    center

    Center of the circle

    radius

    Radius of the circle

  • Instantiate a new Circle

    Declaration

    Swift

    public convenience init(x: Double, y: Double, radius: Double)

    Parameters

    x

    Center X coordinate

    y

    Center Y coordinate

    radius

    Radius of the circle

  • A Rectangle that contains the receiver

    Declaration

    Swift

    public var boundingBox: Rectangle { get }
  • Generate a cubic Bézier representing an arc around a circle.

    Adapted from Joe Cridge

    Note

    Bézier approximations of circles only work up to ~90º

    Declaration

    Swift

    public func acuteArc(start: Radians, size: Radians) -> BezierPath

    Parameters

    start

    Starting angle of the arc, in radians

    size

    Size of the arc, in radians

    circle

    Circle to make the arc on

  • Calculate points of intersection with another shape.

    Declaration

    Swift

    func intersections(with otherShape: Intersectable) -> [Vector]

    Parameters

    otherShape

    The shape with which to find intersection points

    Return Value

    An array of Vectors

  • Calculate points of intersection with a Line

    Declaration

    Swift

    func intersection(with otherShape: Line) -> [Vector]

    Parameters

    otherShape

    The shape with which to find intersection points

    Return Value

    An array of Vectors

  • Calculate points of intersection with a Circle

    Declaration

    Swift

    func intersection(with otherShape: Circle) -> [Vector]

    Parameters

    otherShape

    The shape with which to find intersection points

    Return Value

    An array of Vectors

  • Calculate points of intersection with a Rectangle

    Declaration

    Swift

    func intersection(with otherShape: Rectangle) -> [Vector]

    Parameters

    otherShape

    The shape with which to find intersection points

    Return Value

    An array of Vectors

  • Create a Bézier arc of the circle between the two points.

    Declaration

    Swift

    public func bezierCurve(start: Radians, end: Radians) -> [BezierPath]

    Parameters

    start

    Starting angle

    end

    Ending Angle

    Return Value

    An array of BezierPath which draw the shape

  • Create a XMLElement representing the receiver

    Declaration

    Swift

    public func svgElement() -> XMLElement
  • Draw the receiver in the specified context

    Declaration

    Swift

    public func draw(in context: CGContext)

    Parameters

    context

    Context in which to draw

  • Draw a representation of the receiver meant for debugging the shape in the specified context

    Declaration

    Swift

    public func debugDraw(in context: CGContext)

    Parameters

    context

    Context in which to draw

  • Return the intersection of a ray

    Based on this [algorithm ][] by Деян Добромиров, and an explanation of t values by Victor Li.

    Declaration

    Swift

    public func rayIntersection(_ ray: Ray) -> Vector?

    Parameters

    origin

    Origin of the ray

    dir

    Direction of the ray

  • Returns a Boolean value indicating whether two values are equal.

    Equality is the inverse of inequality. For any values a and b, a == b implies that a != b is false.

    Declaration

    Swift

    public static func == (lhs: Circle, rhs: Circle) -> Bool
  • Declaration

    Swift

    public func hash(into hasher: inout Hasher)
  • Return the intersection point of the specified angle from the center of the circle

    Declaration

    Swift

    public func point(at angle: Radians) -> Vector

    Parameters

    angle

    The angle

  • Declaration

    Swift

    public func angle(ofPoint point: Vector) -> Radians
  • Determine whether teh specified point is inside the circle

    This method compares the distance between the center and point to the radius of the circle.

    Declaration

    Swift

    public func contains(_ point: Vector) -> Bool

    Parameters

    point

    Whether the point is inside the circle