~ubuntu-branches/ubuntu/trusty/python-enable/trusty

« back to all changes in this revision

Viewing changes to examples/kiva/wx_gradient.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-10-17 23:10:41 UTC
  • mto: (1.2.1 upstream) (8.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20101017231041-rziowhgl7zhxra2i
Tags: upstream-3.3.2
ImportĀ upstreamĀ versionĀ 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import with_statement
 
2
 
1
3
import wx
2
4
import numpy
3
5
 
17
19
        gc.clear()
18
20
 
19
21
        # diagonal
20
 
        gc.save_state()
21
 
        gc.rect(50,25,150,100)
22
 
        gc.linear_gradient(50,25,150,125,
23
 
                            numpy.array([starting_color, ending_color]),
24
 
                            "pad", 'objectBoundingBox')
25
 
        gc.draw_path()
26
 
        gc.restore_state()
 
22
        with gc:
 
23
            gc.rect(50,25,150,100)
 
24
            gc.linear_gradient(50,25,150,125,
 
25
                                numpy.array([starting_color, ending_color]),
 
26
                                "pad", 'objectBoundingBox')
 
27
            gc.draw_path()
27
28
 
28
29
        # vertical
29
 
        gc.save_state()
30
 
        gc.rect(50,150,150,100)
31
 
        gc.linear_gradient(50,150,50,250,
32
 
                            numpy.array([starting_color, ending_color]),
33
 
                            "pad", 'objectBoundingBox')
34
 
        gc.draw_path()
35
 
        gc.restore_state()
 
30
        with gc:
 
31
            gc.rect(50,150,150,100)
 
32
            gc.linear_gradient(50,150,50,250,
 
33
                                numpy.array([starting_color, ending_color]),
 
34
                                "pad", 'objectBoundingBox')
 
35
            gc.draw_path()
36
36
 
37
37
        # horizontal
38
 
        gc.save_state()
39
 
        gc.rect(50,275,150,100)
40
 
        gc.linear_gradient(50,275,150,275,
41
 
                            numpy.array([starting_color, ending_color]),
42
 
                            "pad", 'objectBoundingBox')
43
 
        gc.draw_path()
44
 
        gc.restore_state()
 
38
        with gc:
 
39
            gc.rect(50,275,150,100)
 
40
            gc.linear_gradient(50,275,150,275,
 
41
                                numpy.array([starting_color, ending_color]),
 
42
                                "pad", 'objectBoundingBox')
 
43
            gc.draw_path()
45
44
        
46
45
        # radial
47
 
        gc.save_state()
48
 
        gc.arc(325, 75, 50, 0.0, 2*numpy.pi)
49
 
        gc.radial_gradient(325, 75, 50, 325, 75,
50
 
                            numpy.array([starting_color, ending_color]),
51
 
                            "pad", 'objectBoundingBox')
52
 
        gc.draw_path()
53
 
        gc.restore_state()
54
 
 
 
46
        with gc:
 
47
            gc.arc(325, 75, 50, 0.0, 2*numpy.pi)
 
48
            gc.radial_gradient(325, 75, 50, 325, 75,
 
49
                                numpy.array([starting_color, ending_color]),
 
50
                                "pad", 'objectBoundingBox')
 
51
            gc.draw_path()
55
52
 
56
53
        # radial with focal point in upper left
57
 
        gc.save_state()
58
 
        gc.arc(325, 200, 50, 0.0, 2*numpy.pi)
59
 
        gc.radial_gradient(325, 200, 50, 300, 225,
 
54
        with gc:
 
55
            gc.arc(325, 200, 50, 0.0, 2*numpy.pi)
 
56
            gc.radial_gradient(325, 200, 50, 300, 225,
60
57
                            numpy.array([starting_color, ending_color]),
61
58
                            "pad", 'objectBoundingBox')
62
 
        gc.draw_path()
63
 
        gc.restore_state()
 
59
            gc.draw_path()
64
60
 
65
61
        # radial with focal point in bottom right
66
 
        gc.save_state()
67
 
        gc.arc(325, 325, 50, 0.0, 2*numpy.pi)
68
 
        gc.radial_gradient(325, 325, 50, 350, 300,
69
 
                            numpy.array([starting_color, ending_color]),
70
 
                            "pad", 'objectBoundingBox')
71
 
        gc.draw_path()
72
 
        gc.restore_state()
 
62
        with gc:
 
63
            gc.arc(325, 325, 50, 0.0, 2*numpy.pi)
 
64
            gc.radial_gradient(325, 325, 50, 350, 300,
 
65
                                numpy.array([starting_color, ending_color]),
 
66
                                "pad", 'objectBoundingBox')
 
67
            gc.draw_path()
73
68
 
74
69
        return
75
70