Programmer Reference : Common Graphics : Using graphics contexts
Using graphics contexts
A Graphics Context or GC is an object that contains drawing attribute information, such as foreground color, background color, line width, and line style. When an object is drawn on a drawable, the drawable references the graphics context to determine how the object should appear.
Normally, an application creates and uses at least one GC. Your application can create and use many graphics contexts, however. You should use multiple graphics contexts carefully as they are relatively expensive to build and maintain.
For optimum performance, you should draw as much as possible with the same GC, minimizing the number of times you change its components. The cost of changing GC components relative to using different GCs depends on the specific platform because some servers cache a limited number of GCs in the display hardware.
For interactive experimentation and testing, there is a default GC that can be accessed using CgScreen default defaultGC or CgGC default.
Note:
The default GC is intended only for experimentation and testing. Applications should create their own GCs.
In the following figure, a drawable (the root window of the default screen) receives a message to draw a 100x100 filled rectangle at 20@20. The programmer provides a graphics context called aGC. The drawable references aGC to find out how to display the rectangle.
C:\Users\documentation\Documents\vastePublisher\stable\VAS Documentation Word\images\sp006010.gif

Last modified date: 12/21/2017