~ubuntu-branches/ubuntu/maverick/wxwidgets2.8/maverick-proposed

« back to all changes in this revision

Viewing changes to wxPython/demo/GraphicsContext.py

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2007-11-06 18:25:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20071106182513-809agqds6igh7mqo
Tags: 2.8.6.1-0ubuntu1
* New upstream version, based on the upstream tarball
  wxPython-src-2.8.6.1.tar.bz2, renamed debian to debian-upstream.
* Provide a get-orig-source target to do the repackaging.
* Fix "substvar-source-version-is-deprecated" lintian warnings.
* Remove duplicate Description field in debian/control.
* Add "\" at the end of line 8 in debian/python-wxtools.menu to fix
  "bad-test-in-menu-item" lintian error.
* Provide .xpm icons to fix "menu-icon-not-in-xpm-format" lintian errors,
  changed Icon field in debian/python-wxtools.menu.
* Fix "wrong-name-for-upstream-changelog" lintian warnings.
* Remove "Application;" from Categories field in debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Switch "Apps" to "Applications" in debian/python-wxtools.menu to fix
  "menu-item-uses-apps-section" lintian warnings.
* Drop the icon extension from debian/pycrust.desktop,
  debian/pyshell.desktop, debian/xrced.desktop.
* Add dpatch support.
* Add "WX_CONFIG" patch.
* debian/rules:
  - added .xpm icons to install-gtk-py-tools target
  - added "docs/changes.txt" to dh_installchangelogs in binary-common target
  - added "\" at the end of "install-examples install-msw-dev
    install-msw-dbg install-headers-msw" line in .PHONY

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import colorsys
4
4
from math import cos, sin, radians
5
5
 
 
6
from Main import opj
 
7
 
6
8
#----------------------------------------------------------------------
7
9
 
8
10
BASE  = 80.0    # sizes used in shapes drawn below
53
55
        for label, PathFunc in [("StrokePath", gc.StrokePath),
54
56
                                ("FillPath",   gc.FillPath),
55
57
                                ("DrawPath",   gc.DrawPath)]:
56
 
            if "wxGTK" in wx.PlatformInfo:
57
 
                w, h = dc.GetTextExtent(label) # NYI in Cairo context
58
 
            else:
59
 
                w, h = gc.GetTextExtent(label)
60
 
 
61
 
            gc.DrawText(label, -w/2, -BASE2-h)
 
58
            w, h = gc.GetTextExtent(label)
 
59
            
 
60
            gc.DrawText(label, -w/2, -BASE2-h-4)
62
61
            PathFunc(path)
63
62
            gc.Translate(2*BASE, 0)
64
63
 
88
87
        gc.PushState()             # save it again
89
88
        gc.Translate(400, 200)
90
89
        gc.DrawText("Rotate", 0, -BASE2)
91
 
        
 
90
 
 
91
        # Move the origin over to the next location
92
92
        gc.Translate(0, 75)
 
93
 
 
94
        # draw our path again, rotating it about the central point,
 
95
        # and changing colors as we go
93
96
        for angle in range(0, 360, 30):
94
 
            gc.PushState()         # save this new current state so we can pop back to 
95
 
                                   # it at the end of the loop
 
97
            gc.PushState()         # save this new current state so we can 
 
98
                                   # pop back to it at the end of the loop
96
99
            r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(float(angle)/360, 1, 1)]
97
100
            gc.SetBrush(wx.Brush(wx.Colour(r, g, b, 64)))
98
 
 
 
101
            gc.SetPen(wx.Pen(wx.Colour(r, g, b, 128)))
 
102
            
99
103
            # use translate to artfully reposition each drawn path
100
104
            gc.Translate(1.5 * BASE2 * cos(radians(angle)),
101
105
                         1.5 * BASE2 * sin(radians(angle)))
107
111
            gc.DrawPath(path)
108
112
            gc.PopState()
109
113
 
 
114
        # Draw a bitmap with an alpha channel on top of the last group
 
115
        bmp = wx.Bitmap(opj('bitmaps/toucan.png'))
 
116
        bsz = bmp.GetSize()
 
117
        gc.DrawBitmap(bmp,
 
118
                      #-bsz.width, 
 
119
                      #-bsz.height/2,
 
120
 
 
121
                      -bsz.width/2.5, 
 
122
                      -bsz.height/2.5,
 
123
                      
 
124
                      bsz.width, bsz.height)
 
125
 
 
126
 
110
127
        gc.PopState()
111
128
        
112
129