-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhello_drawing_area_manual.rb
139 lines (117 loc) · 4.65 KB
/
hello_drawing_area_manual.rb
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
require 'glimmer-dsl-gtk'
include Glimmer
window {
title 'Hello, Drawing Area (Manual)!'
default_size 400, 400
drawing_area {
on(:draw) do |drawing_area_widget, cairo_context|
cairo_context.set_source_rgb(255/255.0, 255/255.0, 255/255.0)
cairo_context.paint
cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
cairo_context.set_source_rgb(255, 0, 0)
cairo_context.fill
cairo_context.arc(85, 85, 45, (Math::PI/180)*90, -(Math::PI/180)*90)
cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
cairo_context.set_source_rgb(255/255.0, 0, 0)
cairo_context.fill
cairo_context.arc(85, 185, 45, (Math::PI/180)*100, -(Math::PI/180)*30)
cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.circle(85, 285, 45)
cairo_context.set_source_rgb(255/255.0, 0, 0)
cairo_context.fill
cairo_context.circle(85, 285, 45)
cairo_context.set_source_rgb(0, 128/255.0, 255/255.0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.rectangle(140, 40, 180, 90)
cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
cairo_context.fill
cairo_context.rectangle(140, 40, 180, 90)
cairo_context.set_source_rgb(255/255.0, 0, 0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
cairo_context.fill
cairo_context.rounded_rectangle(140, 140, 180, 90, 30, 20)
cairo_context.set_source_rgb(255/255.0, 0, 0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.triangle(140, 240, 320, 240, 230, 330)
cairo_context.set_source_rgb(255/255.0, 255/255.0, 0)
cairo_context.fill
cairo_context.triangle(140, 240, 320, 240, 230, 330)
cairo_context.set_source_rgb(255/255.0, 0, 0)
cairo_context.set_line_width(3)
cairo_context.stroke
cairo_context.new_path
cairo_context.move_to 160, 100
cairo_context.curve_to 190, 60, 200, 80, 210, 70
cairo_context.curve_to 240, 80, 250, 100, 260, 90
cairo_context.curve_to 290, 90, 300, 110, 310, 100
cairo_context.set_source_rgb(0, 255/255.0, 0)
cairo_context.fill
cairo_context.new_path
cairo_context.move_to 160, 100
cairo_context.curve_to 190, 60, 200, 80, 210, 70
cairo_context.curve_to 240, 80, 250, 100, 260, 90
cairo_context.curve_to 290, 90, 300, 110, 310, 100
cairo_context.set_source_rgb(0, 0, 255/255.0)
cairo_context.stroke
cairo_context.new_path
cairo_context.move_to 200, 150
cairo_context.line_to 270, 170
cairo_context.line_to 250, 220
cairo_context.line_to 220, 190
cairo_context.line_to 200, 200
cairo_context.line_to 180, 170
cairo_context.close_path
cairo_context.set_source_rgb(0, 255/255.0, 0)
cairo_context.fill
cairo_context.new_path
cairo_context.move_to 200, 150
cairo_context.line_to 270, 170
cairo_context.line_to 250, 220
cairo_context.line_to 220, 190
cairo_context.line_to 200, 200
cairo_context.line_to 180, 170
cairo_context.close_path
cairo_context.set_source_rgb(0, 0, 255/255.0)
cairo_context.stroke
cairo_context.new_path
cairo_context.move_to 200, 260
cairo_context.line_to 270, 270
cairo_context.line_to 250, 290
cairo_context.line_to 220, 290
cairo_context.line_to 200, 280
cairo_context.line_to 180, 270
cairo_context.close_path
cairo_context.set_source_rgb(0, 255/255.0, 0)
cairo_context.fill
cairo_context.new_path
cairo_context.move_to 200, 260
cairo_context.line_to 270, 270
cairo_context.line_to 250, 290
cairo_context.line_to 220, 290
cairo_context.line_to 200, 280
cairo_context.line_to 180, 270
cairo_context.close_path
cairo_context.set_source_rgb(0, 0, 255/255.0)
cairo_context.stroke
cairo_context.new_path
cairo_context.move_to 200, 260
cairo_context.move_to 270, 320
cairo_context.line_to 250, 340
cairo_context.line_to 220, 340
cairo_context.line_to 200, 330
cairo_context.line_to 180, 320
cairo_context.set_source_rgb(0, 0, 255/255.0)
cairo_context.stroke
end
}
}.show