I have an issue with drawing lines on top of each other in OS X. The following code draws a red rectangle and then the same rectangle in green color. I would expect a green rectangle as a result because it is drawn last. I get a mixture of red and green - olive green. How to modify the code to get green rectangle in this situation?
import Cocoa
class TestView : NSView {
override func drawRect (dirtyRect : NSRect) {
super.drawRect (dirtyRect)
let rect = NSRect (x : 100 , y : 200 , width : 100 , height : 100)
var p = NSBezierPath ()
var c = NSColor (red : 1 , green : 0 , blue : 0 , alpha : 1)
c.set ()
p.appendBezierPathWithRect (rect)
p.stroke ()
p = NSBezierPath ()
c = NSColor (red : 0 , green : 1 , blue : 0 , alpha : 1)
c.set ()
p.appendBezierPathWithRect (rect)
p.stroke ()
}
}
Thanks/Mikael