Challenge: Gradients

Here’s my solution to the challenge on drawing a gradient on the die.

        // Challenge: Gradients.
        let dieShape = NSBezierPath()
        dieShape.appendBezierPathWithRoundedRect(dieFrame, xRadius: cornerRadius, yRadius: cornerRadius)
        
        let dieGradient = NSGradient.init(startingColor: NSColor.whiteColor(), endingColor: NSColor.blueColor())
        dieGradient?.drawInBezierPath(dieShape, angle: 90.0)

This will draw a blue gradient through the die.

Cheers
Wayne

1 Like

Thanks a lot, Wayne!