0

I'm trying to draw a partial circle with a NSBezierPath in an Xcode7 playground, and thanks to the answer here and some of the code here I was able to get the shape up...but for some reason, changing the stroke and fill colors is confounding me.

Here is my playground code right now:

import Cocoa

extension NSBezierPath {

func addArcWithCenter(center: NSPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) {
    let startAngleRadian = ((startAngle) * CGFloat((180.0 / M_PI)))
    let endAngleRadian = ((endAngle) * CGFloat((180.0 / M_PI)))
    self.appendBezierPathWithArcWithCenter(center, radius: radius, startAngle: startAngleRadian, endAngle: endAngleRadian, clockwise: !clockwise)

}

convenience init(arcCenter center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) {
    self.init()
    self.addArcWithCenter(center, radius: radius, startAngle: startAngle, endAngle: endAngle, clockwise: clockwise)

}

}

let strokeColor = NSColor(red: 1.0, green: 0.0, blue: 0.0, alpha: 1.0)
strokeColor.setStroke()
let fillColor = NSColor(red: 0.0, green: 1.0, blue: 0.0, alpha: 1.0)
fillColor.setFill()


let circleCenter = CGPointMake(100, 100)
let circleRadius = CGFloat(80)
var decimalInput  = 0.25
let start = CGFloat(3 * M_PI_2)
let end  = start + CGFloat(4 * M_PI_2 * decimalInput)
let circlePath = NSBezierPath(arcCenter: circleCenter, radius: circleRadius, startAngle: start, endAngle: end, clockwise: true)

circlePath.lineWidth = 4
circlePath.stroke()

I expect a red stroke color here, with a green fill. Instead, I continue to get: enter image description here

I'm sure I'm missing something obvious here.

Community
  • 1
  • 1
Steven Hovater
  • 1,389
  • 2
  • 12
  • 25

0 Answers0