]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/AlphaDrawing.py
4 #----------------------------------------------------------------------
6 class TestPanel(wx
.Panel
):
7 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1)
10 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
13 If this build of wxPython includes the new wx.GCDC class (which
14 provides the wx.DC API on top of the new wx.GraphicsContext class)
15 then these squares should be transparent.
17 wx
.StaticText(self
, -1, txt
, (20, 20))
20 def OnPaint(self
, evt
):
21 pdc
= wx
.PaintDC(self
)
26 rect
= wx
.Rect(0,0, 100, 100)
27 for RGB
, pos
in [((178, 34, 34), ( 50, 90)),
28 (( 35, 142, 35), (110, 150)),
29 (( 0, 0, 139), (170, 90))
32 penclr
= wx
.Colour(r
, g
, b
, wx
.ALPHA_OPAQUE
)
33 brushclr
= wx
.Colour(r
, g
, b
, 128) # half transparent
34 dc
.SetPen(wx
.Pen(penclr
))
35 dc
.SetBrush(wx
.Brush(brushclr
))
37 dc
.DrawRoundedRectangleRect(rect
, 8)
40 #----------------------------------------------------------------------
42 def runTest(frame
, nb
, log
):
43 win
= TestPanel(nb
, log
)
46 #----------------------------------------------------------------------
50 overview
= """<html><body>
51 <h2><center>Alpha Drawing</center></h2>
53 The wx.GCDC class is a class that implemented the wx.DC API using the
54 new wx.GraphicsContext class, and so it supports anti-aliased drawing
55 using pens and brushes, that can optionally also be drawn using an
56 alpha transparency. (On the Mac all the DC classes are using this new
57 implementation.) This is accomplished by enabling the wx.Colour class
58 to have a fourth component for the alpha value, where 0 is fully
59 transparent, and 255 is fully opaque.
66 if __name__
== '__main__':
69 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])