nyle 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,69 @@
1
+
2
+ require 'nyle'
3
+
4
+ class Screen < Nyle::Screen
5
+ def initialize
6
+ super
7
+ @image1 = Nyle.load_image("./image/n_b_crocodile.png")
8
+ @image2 = Nyle.load_image("./image/n_b_river.gif")
9
+ end
10
+
11
+ def draw
12
+ # line
13
+ Nyle.draw_line( 40, 100, 70, 10)
14
+ Nyle.draw_line( 80, 100, 110, 10, {weight: 10})
15
+ Nyle.draw_line(120, 100, 150, 10, {weight: 10, cap: :ROUND})
16
+ for a in (1..10)
17
+ Nyle.draw_line(120 + a * 40, 100, 150 + a * 40, 10, {weight: 10, cap: :ROUND, color: :DARK_GREEN, a: a / 10.0})
18
+ end
19
+
20
+ # circle
21
+ Nyle.draw_circle( 70, 150, 30)
22
+ Nyle.draw_circle(170, 150, 30, {weight: 5})
23
+ Nyle.draw_circle(270, 150, 30, {weight: 5, color: :ORANGE})
24
+ Nyle.draw_circle(370, 150, 30, {color: :ORANGE, fill: true, a: 0.6})
25
+
26
+ # rectangle
27
+ Nyle.draw_rect( 40, 200, 60, 30)
28
+ Nyle.draw_rect(140, 200, 60, 30, {weight: 5})
29
+ Nyle.draw_rect(240, 200, 60, 30, {weight: 5, color: :ORANGE})
30
+ Nyle.draw_rect(340, 200, 60, 30, {color: :ORANGE, fill: true, a: 0.6})
31
+ Nyle.draw_rect(440, 200, 60, 30, {weight: 5, color: :ORANGE, round: 5})
32
+ Nyle.draw_rect(540, 200, 60, 30, {color: :ORANGE, fill: true, round: 5, a: 0.6})
33
+
34
+ Nyle.draw_rect( 45, 250, 50, 30, {weight: 3, color: :GOLD})
35
+ Nyle.cr.save do
36
+ for i in (1..5) do
37
+ # rectangle (coordinate transformation)
38
+ Nyle.rotate(Math::PI / 80)
39
+ Nyle.translate(80, -10)
40
+ Nyle.scale(1.1, 1.1)
41
+ Nyle.draw_rect( 45, 250, 50, 30, {weight: 3, color: :GOLD, fill: true, round: 2})
42
+ end
43
+ end
44
+
45
+ # text
46
+ Nyle.draw_text(40, 375, "【Nyle】", {color: :DARK_GREEN})
47
+ Nyle.draw_text(60, 410, " minimal graphics framework", {color: :DARK_GREEN, size: 24, a: 0.8})
48
+ Nyle.draw_text(70, 440, " using Ruby/GTK3 and Cairo", {color: :DARK_GREEN, size: 24, a: 0.8})
49
+
50
+ # image
51
+ Nyle.draw_image(470, 70, @image1)
52
+ Nyle.draw_image(440, 260, @image2)
53
+
54
+ # key status
55
+ puts "[ctrl] + [shift]" if Nyle.mask_control? and Nyle.mask_shift?
56
+
57
+ # mouse status
58
+ for k in (1..3)
59
+ puts "Nyle.mouse_press?(#{k})" if Nyle.mouse_press?(k)
60
+ end
61
+
62
+ Nyle.quit if Nyle.key_press?(KEY_Escape)
63
+ end
64
+ end
65
+
66
+
67
+ Screen.new.show_all
68
+ Gtk.main
69
+
@@ -0,0 +1,70 @@
1
+
2
+ require 'nyle'
3
+
4
+ class Screen < Nyle::Screen
5
+ include Nyle
6
+ def initialize
7
+ super
8
+ @image1 = load_image("./image/n_b_crocodile.png")
9
+ @image2 = load_image("./image/n_b_river.gif")
10
+ end
11
+
12
+ def draw
13
+ # line
14
+ draw_line( 40, 100, 70, 10)
15
+ draw_line( 80, 100, 110, 10, {weight: 10})
16
+ draw_line(120, 100, 150, 10, {weight: 10, cap: :ROUND})
17
+ for a in (1..10)
18
+ draw_line(120 + a * 40, 100, 150 + a * 40, 10, {weight: 10, cap: :ROUND, color: :DARK_GREEN, a: a / 10.0})
19
+ end
20
+
21
+ # circle
22
+ draw_circle( 70, 150, 30)
23
+ draw_circle(170, 150, 30, {weight: 5})
24
+ draw_circle(270, 150, 30, {weight: 5, color: :ORANGE})
25
+ draw_circle(370, 150, 30, {color: :ORANGE, fill: true, a: 0.6})
26
+
27
+ # rectangle
28
+ draw_rect( 40, 200, 60, 30)
29
+ draw_rect(140, 200, 60, 30, {weight: 5})
30
+ draw_rect(240, 200, 60, 30, {weight: 5, color: :ORANGE})
31
+ draw_rect(340, 200, 60, 30, {color: :ORANGE, fill: true, a: 0.6})
32
+ draw_rect(440, 200, 60, 30, {weight: 5, color: :ORANGE, round: 5})
33
+ draw_rect(540, 200, 60, 30, {color: :ORANGE, fill: true, round: 5, a: 0.6})
34
+
35
+ draw_rect( 45, 250, 50, 30, {weight: 3, color: :GOLD})
36
+ cr.save do
37
+ for i in (1..5) do
38
+ # rectangle (coordinate transformation)
39
+ rotate(Math::PI / 80)
40
+ translate(80, -10)
41
+ scale(1.1, 1.1)
42
+ draw_rect( 45, 250, 50, 30, {weight: 3, color: :GOLD, fill: true, round: 2})
43
+ end
44
+ end
45
+
46
+ # text
47
+ draw_text(40, 375, "【Nyle】", {color: :DARK_GREEN})
48
+ draw_text(60, 410, " minimal graphics framework", {color: :DARK_GREEN, size: 24, a: 0.8})
49
+ draw_text(70, 440, " using Ruby/GTK3 and Cairo", {color: :DARK_GREEN, size: 24, a: 0.8})
50
+
51
+ # image
52
+ draw_image(470, 70, @image1)
53
+ draw_image(440, 260, @image2)
54
+
55
+ # key status
56
+ puts "[ctrl] + [shift]" if mask_control? and mask_shift?
57
+
58
+ # mouse status
59
+ for k in (1..3)
60
+ puts "mouse_press?(#{k})" if mouse_press?(k)
61
+ end
62
+
63
+ quit if key_press?(KEY_Escape)
64
+ end
65
+ end
66
+
67
+
68
+ Screen.new.show_all
69
+ Gtk.main
70
+
@@ -0,0 +1,188 @@
1
+
2
+ require 'nyle'
3
+
4
+ class Blocks < Array
5
+ def initialize
6
+ colors = [
7
+ :BLUE,
8
+ :YELLOW,
9
+ :WHITE,
10
+ :RED,
11
+ :GREEN
12
+ ]
13
+ colors.length.times do |y|
14
+ 10.times do |x|
15
+ self << Block.new(21 + 60 * x , 21 + 20 * y, colors[y])
16
+ end
17
+ end
18
+ end
19
+
20
+ def draw
21
+ self.each do |block|
22
+ block.draw
23
+ end
24
+ end
25
+ end
26
+
27
+ class Block
28
+ attr_accessor :x, :y, :width, :height
29
+ def initialize(x, y, color)
30
+ @x = x
31
+ @y = y
32
+ @width = 58
33
+ @height = 18
34
+ @color = color
35
+ end
36
+
37
+ def update
38
+ end
39
+
40
+ def draw
41
+ Nyle.draw_rect(@x, @y, @width, @height, {color: @color, fill: true, round: 2})
42
+ end
43
+ end
44
+
45
+ class Walls < Array
46
+ def initialize
47
+ self << Wall.new( 0, 0, 20, 480, :WHITE)
48
+ self << Wall.new( 0, 0, 640, 20, :WHITE)
49
+ self << Wall.new(620, 0, 20, 480, :WHITE)
50
+ end
51
+
52
+ def draw
53
+ self.each do |wall|
54
+ wall.draw
55
+ end
56
+ end
57
+ end
58
+
59
+ class Wall
60
+ attr_accessor :x, :y, :width, :height
61
+ def initialize(x, y, width, height, color)
62
+ @x = x
63
+ @y = y
64
+ @width = width
65
+ @height = height
66
+ @color = color
67
+ end
68
+
69
+ def update
70
+ end
71
+
72
+ def draw
73
+ Nyle.draw_rect(@x, @y, @width, @height, {color: @color, fill: true})
74
+ end
75
+ end
76
+
77
+ class Paddle
78
+ attr_accessor :x, :y, :width, :height
79
+ def initialize(x, y)
80
+ @x = x
81
+ @y = y
82
+ @width = 100
83
+ @height = 20
84
+ end
85
+
86
+ def update(mx, my)
87
+ @x = mx - @width / 2
88
+ end
89
+
90
+ def draw
91
+ Nyle.draw_rect(@x, @y, @width, @height, {color: :WHITE, fill: true})
92
+ end
93
+ end
94
+
95
+ class Ball
96
+ def initialize(x, y)
97
+ @x = x
98
+ @y = y
99
+ @r = 10
100
+ @dx = 4
101
+ @dy = -4
102
+ end
103
+
104
+ def update(walls, blocks, paddle)
105
+ @x +=@dx
106
+ if _atari_array?(walls) or _atari?(paddle)
107
+ @x -= @dx
108
+ @dx *= -1
109
+ end
110
+
111
+ @y +=@dy
112
+ if _atari_array?(walls) or _atari?(paddle)
113
+ @y -= @dy
114
+ @dy *= -1
115
+ end
116
+
117
+ blocks.delete_if do |block|
118
+ if _atari?(block)
119
+ @y -= @dy
120
+ @dy *= -1
121
+ end
122
+ end
123
+ end
124
+
125
+ def draw
126
+ Nyle.draw_circle(@x, @y, @r, {color: :WHITE, fill: true})
127
+ end
128
+
129
+ private def _atari?(aite)
130
+ x0 = @x - @r
131
+ xx0 = @x + @r
132
+ y0 = @y - @r
133
+ yy0 = @y + @r
134
+ x = aite.x
135
+ xx = aite.x + aite.width
136
+ y = aite.y
137
+ yy = aite.y + aite.height
138
+
139
+ (x <= x0 && x0 <= xx ||
140
+ x <= xx0 && xx0 <= xx) &&
141
+ (y <= y0 && y0 <= yy ||
142
+ y <= yy0 && yy0 <= yy)
143
+ end
144
+
145
+ private def _atari_array?(array)
146
+ array.each do |a|
147
+ if _atari?(a)
148
+ return true
149
+ end
150
+ end
151
+ false
152
+ end
153
+ end
154
+
155
+
156
+ class Screen < Nyle::Screen
157
+ def initialize
158
+ super(640, 480, {bgcolor: :BLACK})
159
+ setup
160
+ end
161
+
162
+ def setup
163
+ @blocks = Blocks.new
164
+ @walls = Walls.new
165
+ @paddle = Paddle.new(0, 460)
166
+ @ball = Ball.new(300, 400)
167
+ end
168
+
169
+ def draw
170
+ @blocks.draw
171
+ @walls.draw
172
+ @paddle.draw
173
+ @ball.draw
174
+ end
175
+
176
+ def update
177
+ @paddle.update(Nyle.mouse_x, Nyle.mouse_y)
178
+ @ball.update(@walls, @blocks, @paddle)
179
+
180
+ Nyle.quit if Nyle.key_press?(KEY_Escape)
181
+ end
182
+
183
+ end
184
+
185
+
186
+ Screen.new.show_all
187
+ Gtk.main
188
+
@@ -0,0 +1,309 @@
1
+
2
+ require 'nyle'
3
+
4
+ class Screen < Nyle::Screen
5
+ def initialize
6
+ super(480, 600)
7
+ setup
8
+ end
9
+
10
+ def setup
11
+ @colors = [
12
+ :ALICE_BLUE, # #F0F8FF
13
+ :ALIZARIN_CRIMSON, # #E32636
14
+ :AMARANTH, # #E52B50
15
+ :AMBER, # #FFBF00
16
+ :AMETHYST, # #9966CC
17
+ :ANTIQUE_WHITE, # #FAEBD7
18
+ :APRICOT, # #FBCEB1
19
+ :AQUA, # #00FFFF
20
+ :AQUAMARINE, # #7FFFD4
21
+ :ASPARAGUS, # #7BA05B
22
+ :AZURE, # #007FFF/#F0FFFF
23
+ :BEIGE, # #F5F5DC
24
+ :BISQUE, # #FFE4C4
25
+ :BISTRE, # #3D2B1F
26
+ :BLACK, # #000000
27
+ :BLANCHED_ALMOND, # #FFEBCD
28
+ :BLAZE_ORANGE, # #FF6600
29
+ :BLUE, # #0000FF
30
+ :BLUE_VIOLET, # #8A2BE2
31
+ :BONDI_BLUE, # #0095B6
32
+ :BRIGHT_GREEN, # #66FF00
33
+ :BRIGHT_TURQUOISE, # #08E8DE
34
+ :BROWN, # #964B00/#A52A2A
35
+ :BUFF, # #F0DC82
36
+ :BURGUNDY, # #900020
37
+ :BURLY_WOOD, # #DEB887
38
+ :BURNT_ORANGE, # #CC5500
39
+ :BURNT_SIENNA, # #E97451
40
+ :BURNT_UMBER, # #8A3324
41
+ :CADET_BLUE, # #5F9EA0
42
+ :CAMOUFLAGE_GREEN, # #78866B
43
+ :CARDINAL, # #C41E3A
44
+ :CARMINE, # #960018
45
+ :CARNATION, # #F95A61
46
+ :CARROT_ORANGE, # #ED9121
47
+ :CELADON, # #ACE1AF
48
+ :CERISE, # #DE3163
49
+ :CERULEAN, # #007BA7
50
+ :CERULEAN_BLUE, # #2A52BE
51
+ :CHARTREUSE, # #7FFF00
52
+ :CHARTREUSE_YELLOW, # #DFFF00
53
+ :CHESTNUT, # #CD5C5C
54
+ :CHOCOLATE, # #D2691E
55
+ :CINNAMON, # #7B3F00
56
+ :COBALT, # #0047AB
57
+ :COPPER, # #B87333
58
+ :COPPER_ROSE, # #996666
59
+ :CORAL, # #FF7F50
60
+ :CORAL_RED, # #FF4040
61
+ :CORN, # #FBEC5D
62
+ :CORNFLOWER_BLUE, # #6495ED
63
+ :CORNSILK, # #FFF8DC
64
+ :CREAM, # #FFFDD0
65
+ :CRIMSON, # #DC143C
66
+ :CYAN, # #00FFFF
67
+ :DARK_BLUE, # #0000C8/#00008B
68
+ :DARK_CYAN, # #008B8B
69
+ :DARK_GOLDENROD, # #B8860B
70
+ :DARK_GRAY, # #A9A9A9
71
+ :DARK_GREEN, # #006400
72
+ :DARK_KHAKI, # #BDB76B
73
+ :DARK_MAGENTA, # #8B008B
74
+ :DARK_OLIVE_GREEN, # #556B2F
75
+ :DARK_ORANGE, # #FF8C00
76
+ :DARK_ORCHID, # #9932CC
77
+ :DARK_POWDER_BLUE, # #003399
78
+ :DARK_RED, # #8B0000
79
+ :DARK_SALMON, # #E9967A
80
+ :DARK_SEA_GREEN, # #8FBC8F
81
+ :DARK_SLATE_BLUE, # #483D8B
82
+ :DARK_SLATE_GRAY, # #2F4F4F
83
+ :DARK_TURQUOISE, # #00CED1
84
+ :DARK_VIOLET, # #9400D3
85
+ :DEEP_PINK, # #FF1493
86
+ :DEEP_SKY_BLUE, # #00BFFF
87
+ :DENIM, # #1560BD
88
+ :DIM_GRAY, # #696969
89
+ :DODGER_BLUE, # #1E90FF
90
+ :EGGPLANT, # #990066
91
+ :EMERALD, # #50C878
92
+ :FALU_RED, # #801818
93
+ :FERN_GREEN, # #4F7942
94
+ :FIRE_BRICK, # #B22222
95
+ :FLAX, # #EEDC82
96
+ :FLORAL_WHITE, # #FFFAF0
97
+ :FOREST_GREEN, # #228B22
98
+ :FRENCH_ROSE, # #F64A8A
99
+ :FUCHSIA, # #FF00FF
100
+ :GAINSBORO, # #DCDCDC
101
+ :GAMBOGE, # #E49B0F
102
+ :GHOST_WHITE, # #F8F8FF
103
+ :GOLD, # #FFD700
104
+ :GOLDENROD, # #DAA520
105
+ :GRAY, # #808080/#BEBEBE
106
+ :GRAY_ASPARAGUS, # #465945
107
+ :GREEN, # #00FF00
108
+ :GREEN_YELLOW, # #ADFF2F
109
+ :HARLEQUIN, # #3FFF00
110
+ :HELIOTROPE, # #DF73FF
111
+ :HOLLYWOOD_CERISE, # #F400A1
112
+ :HONEYDEW, # #F0FFF0
113
+ :HOT_MAGENTA, # #FF00CC
114
+ :HOT_PINK, # #FF69B4
115
+ :INDIAN_RED, # #CD5C5C
116
+ :INDIGO, # #4B0082
117
+ :INTERNATIONAL_KLEIN_BLUE, # #002FA7
118
+ :INTERNATIONAL_ORANGE, # #FF4F00
119
+ :IVORY, # #FFFFF0
120
+ :JADE, # #00A86B
121
+ :KHAKI, # #C3B091/#F0E68C
122
+ :KHAKI_X11, # #F0E68C
123
+ :LAVENDER, # #B57EDC/#E6E6FA
124
+ :LAVENDER_BLUE, # #CCCCFF
125
+ :LAVENDER_BLUSH, # #FFF0F5
126
+ :LAVENDER_GRAY, # #BDBBD7
127
+ :LAVENDER_PINK, # #FBAED2
128
+ :LAVENDER_ROSE, # #FBA0E3
129
+ :LAWN_GREEN, # #7CFC00
130
+ :LEMON, # #FDE910
131
+ :LEMON_CHIFFON, # #FFFACD
132
+ :LIGHT_BLUE, # #ADD8E6
133
+ :LIGHT_CORAL, # #F08080
134
+ :LIGHT_CYAN, # #E0FFFF
135
+ :LIGHT_GOLDENROD_YELLOW, # #FAFAD2
136
+ :LIGHT_GREEN, # #90EE90
137
+ :LIGHT_GREY, # #D3D3D3
138
+ :LIGHT_PINK, # #FFB6C1
139
+ :LIGHT_SALMON, # #FFA07A
140
+ :LIGHT_SEA_GREEN, # #20B2AA
141
+ :LIGHT_SKY_BLUE, # #87CEFA
142
+ :LIGHT_SLATE_GRAY, # #778899
143
+ :LIGHT_STEEL_BLUE, # #B0C4DE
144
+ :LIGHT_YELLOW, # #FFFFE0
145
+ :LILAC, # #C8A2C8
146
+ :LIME, # #BFFF00/#00FF00
147
+ :LIME_GREEN, # #32CD32
148
+ :LINEN, # #FAF0E6
149
+ :MAGENTA, # #FF00FF
150
+ :MALACHITE, # #0BDA51
151
+ :MAROON, # #800000/#B03060
152
+ :MAUVE, # #E0B0FF
153
+ :MEDIUM_AQUAMARINE, # #66CDAA
154
+ :MEDIUM_BLUE, # #0000CD
155
+ :MEDIUM_CARMINE, # #AF4035
156
+ :MEDIUM_LAVENDER, # #EE82EE
157
+ :MEDIUM_ORCHID, # #BA55D3
158
+ :MEDIUM_PURPLE, # #9370DB
159
+ :MEDIUM_SEA_GREEN, # #3CB371
160
+ :MEDIUM_SLATE_BLUE, # #7B68EE
161
+ :MEDIUM_SPRING_GREEN, # #00FA9A
162
+ :MEDIUM_TURQUOISE, # #48D1CC
163
+ :MEDIUM_VIOLET_RED, # #C71585
164
+ :MIDNIGHT_BLUE, # #003366/#191970
165
+ :MINT_CREAM, # #F5FFFA
166
+ :MINT_GREEN, # #98FF98
167
+ :MISTY_ROSE, # #FFE4E1
168
+ :MOCCASIN, # #FFE4B5
169
+ :MOSS_GREEN, # #ADDFAD
170
+ :MOUNTBATTEN_PINK, # #997A8D
171
+ :MUSTARD, # #FFDB58
172
+ :NAVAJO_WHITE, # #FFDEAD
173
+ :NAVY_BLUE, # #000080
174
+ :OCHRE, # #CC7722
175
+ :OLD_GOLD, # #CFB53B
176
+ :OLD_LACE, # #FDF5E6
177
+ :OLD_LAVENDER, # #796878
178
+ :OLD_ROSE, # #C08081
179
+ :OLIVE, # #808000
180
+ :OLIVE_DRAB, # #6B8E23
181
+ :ORANGE, # #FFA500
182
+ :ORANGE_COLOR_WHEEL, # #FF7500
183
+ :ORANGE_PEEL, # #FFA000
184
+ :ORANGE_RED, # #FF4500
185
+ :ORANGE_WEB, # #FFA500
186
+ :ORCHID, # #DA70D6
187
+ :PALE_GOLDENROD, # #EEE8AA
188
+ :PALE_GREEN, # #98FB98
189
+ :PALE_TURQUOISE, # #AFEEEE
190
+ :PALE_VIOLET_RED, # #DB7093
191
+ :PAPAYA_WHIP, # #FFEFD5
192
+ :PASTEL_GREEN, # #77DD77
193
+ :PASTEL_PINK, # #FFD1DC
194
+ :PEACH, # #FFE5B4
195
+ :PEACH_ORANGE, # #FFCC99
196
+ :PEACH_PUFF, # #FFDAB9
197
+ :PEACH_YELLOW, # #FADFAD
198
+ :PEAR, # #D1E231
199
+ :PERIWINKLE, # #CCCCFF
200
+ :PERSIAN_BLUE, # #1C39BB
201
+ :PERSIAN_GREEN, # #00A693
202
+ :PERSIAN_INDIGO, # #32127A
203
+ :PERSIAN_PINK, # #F77FBE
204
+ :PERSIAN_RED, # #CC3333
205
+ :PERSIAN_ROSE, # #FF1CB1
206
+ :PERU, # #CD853F
207
+ :PINE_GREEN, # #01796F
208
+ :PINK, # #FFC0CB
209
+ :PINK_ORANGE, # #FF9966
210
+ :PLUM, # #DDA0DD
211
+ :POMEGRANATE, # #F34723
212
+ :POWDER_BLUE, # #B0E0E6
213
+ :POWDER_BLUE_WEB, # #B0E0E6
214
+ :PRUSSIAN_BLUE, # #003153
215
+ :PUCE, # #CC8899
216
+ :PUMPKIN, # #FF7518
217
+ :PURPLE, # #660099/#A020F0
218
+ :RAW_UMBER, # #734A12
219
+ :RED, # #FF0000
220
+ :RED_VIOLET, # #C71585
221
+ :ROBIN_EGG_BLUE, # #00CCCC
222
+ :ROSE, # #FF007F
223
+ :ROSY_BROWN, # #BC8F8F
224
+ :ROYAL_BLUE, # #4169E1
225
+ :RUSSET, # #80461B
226
+ :RUST, # #B7410E
227
+ :SADDLE_BROWN, # #8B4513
228
+ :SAFETY_ORANGE, # #FF6600
229
+ :SAFFRON, # #F4C430
230
+ :SALMON, # #FF8C69/#FA8072
231
+ :SANDY_BROWN, # #F4A460
232
+ :SANGRIA, # #92000A
233
+ :SAPPHIRE, # #082567
234
+ :SCARLET, # #FF2400
235
+ :SCHOOL_BUS_YELLOW, # #FFD800
236
+ :SEA_GREEN, # #2E8B57
237
+ :SEASHELL, # #FFF5EE
238
+ :SELECTIVE_YELLOW, # #FFBA00
239
+ :SEPIA, # #704214
240
+ :SHOCKING_PINK, # #FC0FC0
241
+ :SIENNA, # #A0522D
242
+ :SILVER, # #C0C0C0
243
+ :SKY_BLUE, # #87CEEB
244
+ :SLATE_BLUE, # #6A5ACD
245
+ :SLATE_GRAY, # #708090
246
+ :SMALT, # #003399
247
+ :SNOW, # #FFFAFA
248
+ :SPRING_GREEN, # #00FF7F
249
+ :STEEL_BLUE, # #4682B4
250
+ :SWAMP_GREEN, # #ACB78E
251
+ :TAN, # #D2B48C
252
+ :TANGERINE, # #FFCC00
253
+ :TAUPE, # #483C32
254
+ :TAWNY, # #CD5700
255
+ :TEA_GREEN, # #D0F0C0
256
+ :TEAL, # #008080
257
+ :TENNE, # #CD5700
258
+ :TERRA_COTTA, # #E2725B
259
+ :THISTLE, # #D8BFD8
260
+ :TOMATO, # #FF6347
261
+ :TURQUOISE, # #30D5C8/#40E0D0
262
+ :ULTRAMARINE, # #120A8F
263
+ :VERMILION, # #FF4D00
264
+ :VIOLET, # #8B00FF/#EE82EE
265
+ :VIOLET_EGGPLANT, # #991199
266
+ :VIRIDIAN, # #40826D
267
+ :WHEAT, # #F5DEB3
268
+ :WHITE, # #FFFFFF
269
+ :WHITE_SMOKE, # #F5F5F5
270
+ :WISTERIA, # #C9A0DC
271
+ :YELLOW, # #FFFF00
272
+ :YELLOW_GREEN, # #9ACD32
273
+ :ZINNWALDITE # #EBC2AF
274
+ ]
275
+ @start_index = 0
276
+ @bar_w = 200
277
+ @bar_h = 30
278
+ end
279
+
280
+ def draw
281
+ @colors.each_with_index do |c, i|
282
+ next if i < @start_index
283
+ y = (i - @start_index) * @bar_h
284
+ Nyle.draw_rect(0, y, @bar_w, @bar_h, {color: c, fill: true})
285
+ Nyle.draw_text(@bar_w + 10, y + @bar_h - 10, c.to_s, {color: :BLACK, size: 16})
286
+ end
287
+ end
288
+
289
+ def update
290
+ if Nyle.key_press?(KEY_Up)
291
+ @start_index -= (@height / @bar_h)
292
+ @start_index = (@colors.length / (@height / @bar_h)) * (@height / @bar_h) if @start_index < 0
293
+ # puts "#{@start_index} #{@colors.length}"
294
+ end
295
+
296
+ if Nyle.key_press?(KEY_Down)
297
+ @start_index += (@height / @bar_h)
298
+ @start_index = 0 if @start_index >= @colors.length
299
+ # puts "#{@start_index} #{@colors.length}"
300
+ end
301
+
302
+ Nyle.quit if Nyle.key_press?(KEY_Escape)
303
+ end
304
+ end
305
+
306
+
307
+ Screen.new.show_all
308
+ Gtk.main
309
+