Graphics Contexts and DCs explanations?
arkanes at gmail.com
Tue Aug 19 20:27:14 CEST 2008
On Tue, Aug 19, 2008 at 1:16 PM, RgeeK <Ross at no.thanks.spammers> wrote:
> Experimenting with graphics in an app: it's AUI based with a few panes, one
> of which has a panel containing a few sizers holding UI elements. One sizer
> contains a panel that needs some basic line-drawing graphics in it.
> I use the wxPython demo app heavily to figure this stuff out, and my
> experiments seem to work, but I'm flying blind somewhat.
> Can someone englighten me about the wx.GraphicsContext versus wx.PaintDC
> (BTW what does PaintDC stand for? Drawing Context perhaps?)
> The scrolledWindow and GraphicsContext examples are helpful, but it appears
> I can draw a rectangles, lines and text in either just a straight wxPaintDC,
> or can do:
> dc = wx.PaintDC(self)
> gc = wx.GraphicsContext.Create(dc)
> ...and do the same drawing with gc.DrawText etc...
> Can someone clarify the differences or added value of the gc over the dc,
> and is using the dc alone a valid approach? Where will it end up biting me
> - I don't mean which body part :) Perhaps I should say in which situation
> will it bite...
This is probably better suited to the wxPython ML instead of c.l.p,
because it's so specific.
In short: wxDC (and friends) are traditional raster based drawing
contexts. wxGraphicsContext is a vector/path based API. If you're
doing drawing that's suited for a vector format (like line drawing
probably is), using wxGraphicsContext will give you better image
quality as well as the general vector features like free scaling,
rotation, transforms, etc,
More information about the Python-list