]>
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)
11 wx
.StaticText(self
, -1,
12 "On the Mac these squares should be transparent,\n"
13 "if the CoreGrahics option is turned on.",
16 self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
)
18 def OnPaint(self
, evt
):
20 rect
= wx
.Rect(0,0, 100, 100)
21 for RGB
, pos
in [((178, 34, 34), ( 50, 70)),
22 (( 35, 142, 35), (110, 130)),
23 (( 0, 0, 139), (170, 70))
26 penclr
= wx
.Colour(r
, g
, b
, wx
.ALPHA_OPAQUE
)
27 brushclr
= wx
.Colour(r
, g
, b
, 128) # half transparent
28 dc
.SetPen(wx
.Pen(penclr
))
29 dc
.SetBrush(wx
.Brush(brushclr
))
31 dc
.DrawRectangleRect(rect
)
34 #----------------------------------------------------------------------
36 def runTest(frame
, nb
, log
):
37 win
= TestPanel(nb
, log
)
40 #----------------------------------------------------------------------
44 overview
= """<html><body>
45 <h2><center>Alpha Drawing</center></h2>
47 The wx.DC on Mac now supports alpha transparent drawing using pens and
48 brushes. This is accomplished by enabling the wx.Colour class to have
49 a fourth component for the alpha value, where 0 is fully transparent,
50 and 255 is fully opaque.
57 if __name__
== '__main__':
60 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])