Whats the difference between DC, GC and GCDC

I found some code and begin to play around with it to try and see the differences between those 3.

first of all I did a dir(method) call on all 3 of them and found that DC has 199 methods, GCDC has 204 methods and GC has 76 methods. With the sample code in this link [1] I tested the same functionality with the 3 of them, only DC and GCDC worked, obviously because GC doesnt have the methods like Clear(), SetUserScale(), Etc..

The differences between DC and GCDC where obvious, here are some screenshots with DC[2] and with GCDC[3] (GCDC looks significant better)

my questions are:
what its the reason for having 3 drawing API's?
why GC doesnt have methods like DrawArc(), etc..
which one should be my first option if I want to draw images?

[1] http://pastebin.com/S3fythFy
[2] http://i.imgur.com/GoSyP.png
[3] http://i.imgur.com/9Dr9m.png

I found some code and begin to play around with it to try and see the
differences between those 3.

first of all I did a dir(method) call on all 3 of them and found that DC
has 199 methods, GCDC has 204 methods and GC has 76 methods. With the
sample code in this link [1] I tested the same functionality with the 3
of them, only DC and GCDC worked, obviously because GC doesnt have the
methods like Clear(), SetUserScale(), Etc..

The differences between DC and GCDC where obvious, here are some
screenshots with DC[2] and with GCDC[3] (GCDC looks significant better)

my questions are:
what its the reason for having 3 drawing API's?

wx.DC is the original drawing API that wraps the older, more traditional platform APIs, such as the GDI API functions on Windows and APIs with similar features on the other platforms. It is raster-based, meaning that it deals best with pixel-based information and is not able to deal very well (if at all) with things like anti-aliasing or alpha blending.

wx.GraphicsContext is a newer, more advanced and more powerful drawing API that is based on the newer platform APIs like GDI+ on Windows, CoreGraphics on Mac and Cairo on Linux and elsewhere. It is vector-based, meaning that it is designed to deal with things at a bit higher level of abstraction than pixel level operations and is organized around paths ( collections of lines, curves, etc.) and fills, it can easily do things like scaling, rotating and otherwise modifying the paths using matrix transforms, and the vector information can then be drawn as needed to various back-ends such as a DC. Anti-aliasing and alpha blending are supported and are a core feature of this set of classes.

The wx.GCDC is simply a reimplementation of the wx.DC API using a wx.GraphicsContext underneath.

If you would like to use Cairo on all platforms then take a look at wx.lib.graphics.

why GC doesnt have methods like DrawArc(), etc..

See wx.GraphicsPath.

which one should be my first option if I want to draw images?

It depends on what you will be drawing besides the images, and what you want it to look like and if you want to use any of the advanced features of wx.GraphicsContext. If all you are drawing is the images then there really isn't a whole lot of difference between them. The wx.DC will be a little faster on Windows for (re)drawing bitmaps.

···

On 4/16/11 2:39 PM, PythonJourney wrote:

--
Robin Dunn
Software Craftsman