A simple example of the drawing process
In the following example, the default window is assigned to the temporary variable
drawable. A graphics context called
gc is created for this drawable with no initial values. Notice that the
CgConstants pool dictionary constant
None is used to indicate that no values are being set. In the next line, the foreground color is set to black. (The
blackPixel message, used to get the pixel value for black, is discussed in
"Drawing in black and white".) The drawable is then sent a message to draw a filled rectangle at the appropriate coordinates using the display attributes from the graphics context called
gc. At the end of this routine, the GC is freed, and its resources are returned to the operating system.
| gc drawable |
drawable := CgWindow default.
gc := CqGCdefault
"Set a graphics context attribute."
gc setForeground: drawable blackPixel.
drawable
"Issue a drawing operation."
fillRectangle: gc
x: 100
y: 100
width: 50
height: 50.
Last modified date: 01/29/2015