Custom Drawing

For your first foray into custom drawing, you will start small by drawing a gray background for the DieView and a green line that bisects the view diagonally. (Figure 17.6).

Figure 17.6  Drawing with NSColor and NSBezierPath

Drawing with NSColor and NSBezierPath

Your drawing will be done in three steps:

  • Set the color. The color is an instance of NSColor. NSColor can specify colors in the RGB, HSV, CMYK, and grayscale color spaces.

  • Construct the path. The path specifies the line, curve, or shape that you want to draw. The path is an instance of NSBezierPath. (If you need to draw the same path multiple times, you can store an instance of ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.