Added sample showing Alpha drawing for Mac with CoreGraphics
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41073 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
61
wxPython/demo/AlphaDrawing.py
Normal file
61
wxPython/demo/AlphaDrawing.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
|
||||||
|
import wx
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
class TestPanel(wx.Panel):
|
||||||
|
def __init__(self, parent, log):
|
||||||
|
self.log = log
|
||||||
|
wx.Panel.__init__(self, parent, -1)
|
||||||
|
|
||||||
|
wx.StaticText(self, -1,
|
||||||
|
"On the Mac these squares should be transparent,\n"
|
||||||
|
"if the CoreGrahics option is turned on.",
|
||||||
|
(20, 20))
|
||||||
|
|
||||||
|
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||||
|
|
||||||
|
def OnPaint(self, evt):
|
||||||
|
dc = wx.PaintDC(self)
|
||||||
|
rect = wx.Rect(0,0, 100, 100)
|
||||||
|
for RGB, pos in [((178, 34, 34), ( 50, 70)),
|
||||||
|
(( 35, 142, 35), (110, 130)),
|
||||||
|
(( 0, 0, 139), (170, 70))
|
||||||
|
]:
|
||||||
|
r, g, b = RGB
|
||||||
|
penclr = wx.Colour(r, g, b, wx.ALPHA_OPAQUE)
|
||||||
|
brushclr = wx.Colour(r, g, b, 128) # half transparent
|
||||||
|
dc.SetPen(wx.Pen(penclr))
|
||||||
|
dc.SetBrush(wx.Brush(brushclr))
|
||||||
|
rect.SetPosition(pos)
|
||||||
|
dc.DrawRectangleRect(rect)
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
def runTest(frame, nb, log):
|
||||||
|
win = TestPanel(nb, log)
|
||||||
|
return win
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
overview = """<html><body>
|
||||||
|
<h2><center>Alpha Drawing</center></h2>
|
||||||
|
|
||||||
|
The wx.DC on Mac now supports alpha transparent drawing using pens and
|
||||||
|
brushes. This is accomplished by enabling the wx.Colour class to have
|
||||||
|
a fourth component for the alpha value, where 0 is fully transparent,
|
||||||
|
and 255 is fully opaque.
|
||||||
|
|
||||||
|
</body></html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys,os
|
||||||
|
import run
|
||||||
|
run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
|
||||||
|
|
@@ -60,6 +60,7 @@ _treeList = [
|
|||||||
'BitmapFromBuffer',
|
'BitmapFromBuffer',
|
||||||
'RawBitmapAccess',
|
'RawBitmapAccess',
|
||||||
'DragScroller',
|
'DragScroller',
|
||||||
|
'AlphaDrawing',
|
||||||
]),
|
]),
|
||||||
|
|
||||||
# managed windows == things with a (optional) caption you can close
|
# managed windows == things with a (optional) caption you can close
|
||||||
@@ -232,6 +233,7 @@ _treeList = [
|
|||||||
|
|
||||||
# Images
|
# Images
|
||||||
('Using Images', [
|
('Using Images', [
|
||||||
|
'AlphaDrawing',
|
||||||
'ArtProvider',
|
'ArtProvider',
|
||||||
'BitmapFromBuffer',
|
'BitmapFromBuffer',
|
||||||
'Cursor',
|
'Cursor',
|
||||||
@@ -247,6 +249,7 @@ _treeList = [
|
|||||||
|
|
||||||
# Other stuff
|
# Other stuff
|
||||||
('Miscellaneous', [
|
('Miscellaneous', [
|
||||||
|
'AlphaDrawing',
|
||||||
'ColourDB',
|
'ColourDB',
|
||||||
##'DialogUnits', # needs more explanations
|
##'DialogUnits', # needs more explanations
|
||||||
'DragScroller',
|
'DragScroller',
|
||||||
|
Reference in New Issue
Block a user