-
Notifications
You must be signed in to change notification settings - Fork 44
/
ui_text.py
101 lines (85 loc) · 3.35 KB
/
ui_text.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from enable.api import Component, ComponentEditor
from traits.api import HasTraits, Instance
from traitsui.api import Item, View
def glyph_a(gc):
gc.move_to(28.47, 6.45)
gc.quad_curve_to(21.58, 1.12, 19.82, 0.29)
gc.quad_curve_to(17.19, -0.93, 14.21, -0.93)
gc.quad_curve_to(9.57, -0.93, 6.57, 2.25)
gc.quad_curve_to(3.56, 5.42, 3.56, 10.60)
gc.quad_curve_to(3.56, 13.87, 5.03, 16.26)
gc.quad_curve_to(7.03, 19.58, 11.99, 22.51)
gc.quad_curve_to(16.94, 25.44, 28.47, 29.64)
gc.line_to(28.47, 31.40)
gc.quad_curve_to(28.47, 38.09, 26.34, 40.58)
gc.quad_curve_to(24.22, 43.07, 20.17, 43.07)
gc.quad_curve_to(17.09, 43.07, 15.28, 41.41)
gc.quad_curve_to(13.43, 39.75, 13.43, 37.60)
gc.line_to(13.53, 34.77)
gc.quad_curve_to(13.53, 32.52, 12.38, 31.30)
gc.quad_curve_to(11.23, 30.08, 9.38, 30.08)
gc.quad_curve_to(7.57, 30.08, 6.42, 31.35)
gc.quad_curve_to(5.27, 32.62, 5.27, 34.81)
gc.quad_curve_to(5.27, 39.01, 9.57, 42.53)
gc.quad_curve_to(13.87, 46.04, 21.63, 46.04)
gc.quad_curve_to(27.59, 46.04, 31.40, 44.04)
gc.quad_curve_to(34.28, 42.53, 35.64, 39.31)
gc.quad_curve_to(36.52, 37.21, 36.52, 30.71)
gc.line_to(36.52, 15.53)
gc.quad_curve_to(36.52, 9.13, 36.77, 7.69)
gc.quad_curve_to(37.01, 6.25, 37.57, 5.76)
gc.quad_curve_to(38.13, 5.27, 38.87, 5.27)
gc.quad_curve_to(39.65, 5.27, 40.23, 5.62)
gc.quad_curve_to(41.26, 6.25, 44.19, 9.18)
gc.line_to(44.19, 6.45)
gc.quad_curve_to(38.72, -0.88, 33.74, -0.88)
gc.quad_curve_to(31.35, -0.88, 29.93, 0.78)
gc.quad_curve_to(28.52, 2.44, 28.47, 6.45)
gc.close_path()
gc.move_to(28.47, 9.62)
gc.line_to(28.47, 26.66)
gc.quad_curve_to(21.09, 23.73, 18.95, 22.51)
gc.quad_curve_to(15.09, 20.36, 13.43, 18.02)
gc.quad_curve_to(11.77, 15.67, 11.77, 12.89)
gc.quad_curve_to(11.77, 9.38, 13.87, 7.06)
gc.quad_curve_to(15.97, 4.74, 18.70, 4.74)
gc.quad_curve_to(22.41, 4.74, 28.47, 9.62)
gc.close_path()
class MyCanvas(Component):
def draw(self, gc, **kwargs):
w,h = gc.width(), gc.height()
gc.move_to(0,0)
gc.line_to(w,h)
gc.set_stroke_color((1,0,0))
gc.stroke_path()
gc.move_to(0,h)
gc.line_to(w,0)
gc.set_stroke_color((0,1,0))
gc.stroke_path()
gc.rect(0,0,w,h)
gc.set_stroke_color((0,0,0,.5))
gc.set_line_width(20)
gc.stroke_path()
gc.set_fill_color((0,0,1,0.0))
gc.rect(0,0,w,h)
gc.draw_path()
gc.set_line_width(1)
gc.translate_ctm(w/2.0,h/2.0)
with gc:
gc.scale_ctm(2.0,2.0)
glyph_a(gc)
gc.stroke_path()
gc.translate_ctm(0,-20)
gc.scale_ctm(2.0,2.0)
glyph_a(gc)
gc.set_fill_color((0,0,1,1.0))
gc.fill_path()
class Demo(HasTraits):
canvas = Instance(Component)
traits_view = View(Item('canvas', editor=ComponentEditor(bgcolor="lightgray"),
show_label=False, width=500, height=500),
resizable=True, title="Gradient Example")
def _canvas_default(self):
return MyCanvas()
if __name__ == "__main__":
Demo().configure_traits()