nyle 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42ab8fbeb3f524b4e03c3007e5021196296a4492e62ba78ae2b5a596dcb02a46
4
+ data.tar.gz: 365227d4c2aaf246b5ed0f17cc928b179c533cf90f258fd4533106e91701bd66
5
+ SHA512:
6
+ metadata.gz: 330e8bac463e481d5066c9313ca6ea94cde526727ec88b9e21f1e9bf27259dab1862dfc60bfd32714591e2ac0c2c3887a46c16262e3c6279bcc46bbd6cc5775a
7
+ data.tar.gz: 1b98f3ef0709b13780a335109c5e880a1c371c3993598585ff82845f8e66b966a4365809fd0427cb1cc647db7e444d3d8d7bbe44f1d42452b880a0e38f8d8d60
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ desktop.ini
2
+ *.gem
3
+ bin/
4
+ doc/*.docx
5
+ samples/.bundle/
6
+ samples/Gemfile
7
+ samples/Gemfile.lock
8
+ samples/readme_torun.txt
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nyle.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Nyle
2
+
3
+ 'Nyle' is a minimal graphics framework using Ruby/GTK3 and Cairo.
4
+
5
+ ## Requirements
6
+
7
+ * Ruby/GTK3
8
+ * rsvg2 (for Windows only)
9
+
10
+ ## Installation
11
+
12
+ Install it yourself as:
13
+
14
+ $ gem install nyle
15
+
16
+ Or for Windows
17
+
18
+ $ gem install nyle
19
+ $ gem rsvg2
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ require 'nyle'
25
+ ```
26
+
27
+ ## Documents
28
+
29
+ Reference manual: https://github.com/spoolkitamura/nyle/tree/master/doc/Nyle_reference.pdf
30
+
31
+ ## Samples
32
+
33
+ Reference manual: https://github.com/spoolkitamura/nyle/tree/master/samples
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
Binary file
data/lib/nyle/frame.rb ADDED
@@ -0,0 +1,107 @@
1
+
2
+ =begin
3
+ 'Nyle'
4
+ minimal graphics framework using Ruby/GTK3 and Cairo
5
+
6
+ Copyright (c) 2018 Koki Kitamura
7
+ Released under the MIT license
8
+ https://opensource.org/licenses/mit-license.php
9
+ =end
10
+
11
+ module Nyle
12
+ class Error < StandardError; end
13
+
14
+ # Frame
15
+ class Frame < Gtk::Window
16
+ include Gdk::Keyval # Include key definication to omit 'Gdk::Keyval::' for subclass
17
+ def initialize(width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT, title: DEFAULT_TITLE)
18
+ super()
19
+ self.set_size_request(width, height)
20
+ self.resizable = false
21
+ self.title = title
22
+ @transition = [] # Screen transition table
23
+ @interval_time = ENV['NYLE_INTERVAL'].to_i # milli seconds
24
+ @interval_time = 15 if @interval_time < 5 or @interval_time > 60
25
+ GLib::Timeout.add(@interval_time) do
26
+ if @current_screen
27
+ Nyle.module_eval {
28
+ _update_mouse_state
29
+ _update_key_state
30
+ }
31
+ update
32
+ @current_screen.queue_draw unless @current_screen.destroyed?
33
+ end
34
+ end
35
+
36
+ # Mouse events
37
+ self.add_events([:button_press_mask,
38
+ :button_release_mask])
39
+
40
+ # Signal handler for mouse pressed
41
+ self.signal_connect(:button_press_event) do |widget, event|
42
+ Nyle.module_eval {
43
+ _set_mouse_down(event.button, true)
44
+ }
45
+ false
46
+ end
47
+
48
+ # Signal handler for mouse released
49
+ self.signal_connect(:button_release_event) do |widget, event|
50
+ Nyle.module_eval {
51
+ _set_mouse_down(event.button, false)
52
+ }
53
+ false
54
+ end
55
+
56
+ # Signal handler for key pressed
57
+ self.signal_connect(:key_press_event) do |widget, event|
58
+ Nyle.module_eval {
59
+ _set_key_down(event.keyval, true)
60
+ }
61
+ # [debug]
62
+ # puts "keyname: [#{Gdk::Keyval.to_name(event.keyval)}]"
63
+ false
64
+ end
65
+
66
+ # Signal handler for key released
67
+ self.signal_connect(:key_release_event) do |widget, event|
68
+ Nyle.module_eval {
69
+ _set_key_down(event.keyval, false)
70
+ }
71
+ false
72
+ end
73
+
74
+ self.signal_connect(:destroy) do
75
+ Gtk.main_quit
76
+ end
77
+ end
78
+
79
+ def set_current(screen)
80
+ _set_current(screen)
81
+ end
82
+
83
+ private def _set_current(screen)
84
+ self.remove(@current_screen) if @current_screen
85
+ @current_screen = screen
86
+ self.add(@current_screen)
87
+ w = @current_screen.width
88
+ h = @current_screen.height
89
+ Nyle.module_eval {
90
+ _set_screen_size(w, h)
91
+ }
92
+ end
93
+
94
+ private def update
95
+ @transition.each do |tr|
96
+ if tr[:current] == @current_screen and tr[:status] == @current_screen.status
97
+ tr[:current].instance_eval { suspend } # Suspend for current screen
98
+ tr[:next].instance_eval { resume } # Resume for next screen
99
+ _set_current(tr[:next]) # Change screen
100
+ self.show_all
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ end
107
+
@@ -0,0 +1,106 @@
1
+
2
+ =begin
3
+ 'Nyle'
4
+ minimal graphics framework using Ruby/GTK3 and Cairo
5
+
6
+ Copyright (c) 2018 Koki Kitamura
7
+ Released under the MIT license
8
+ https://opensource.org/licenses/mit-license.php
9
+ =end
10
+
11
+ module Nyle
12
+ class Error < StandardError; end
13
+
14
+ # Screen
15
+ class Screen < Gtk::DrawingArea
16
+ include Gdk::Keyval # Include key definication to omit 'Gdk::Keyval::' for subclass
17
+ attr_reader :width, :height, :status
18
+ def initialize(width = DEFAULT_WIDTH, height = DEFAULT_HEIGHT, bgcolor: :WHITE, trace: false)
19
+ super()
20
+ @width = width
21
+ @height = height
22
+ @trace = trace
23
+ @bgcolor = bgcolor
24
+ @running_count = 0
25
+ @status = nil
26
+
27
+ # Draw to 'CairoContext' of ImageSurface once, and copy to 'CairoContext' of DrawingArea
28
+ if @trace
29
+ # specified color background
30
+ # [WARN] Segmentation Fault happen after a while
31
+ #data = sprintf("%02X%02X%02X%02X", Cairo::Color.parse(@bgcolor).b * 255,
32
+ # Cairo::Color.parse(@bgcolor).g * 255,
33
+ # Cairo::Color.parse(@bgcolor).r * 255, 255) # Hex (e.g. CC7700FF; b=CC, g=77, r=00, a=FF)
34
+ #data = [data].pack("H*") # Pack as binary (e.g. \xCC\x77\x00\xFF)
35
+ #@canvas = Cairo::ImageSurface.new(data * @width * @height, :ARGB32, @width, @height, @width * 4)
36
+ @canvas = Cairo::ImageSurface.new(@width, @height)
37
+ else
38
+ # transparent background
39
+ @canvas = Cairo::ImageSurface.new(@width, @height)
40
+ end
41
+ self.signal_connect(:configure_event) do |widget, event|
42
+ ; # For resizing and so on
43
+ end
44
+
45
+ self.signal_connect(:draw) do |widget, cairo_context|
46
+ # Draw to 'CairoContext' of ImageSurface
47
+ Cairo::Context.new(@canvas) do |cr|
48
+ Nyle.module_eval {
49
+ _set_cr(cr)
50
+ }
51
+ unless @trace # If not trace, fill screen each time
52
+ Nyle.cr.set_source_color(@bgcolor)
53
+ Nyle.cr.paint
54
+ end
55
+ update
56
+ draw
57
+ end
58
+ # Copy to 'CairoContext' of DrawingArea
59
+ Nyle.module_eval {
60
+ _set_cr(cairo_context)
61
+ }
62
+ pattern = Cairo::SurfacePattern.new(@canvas)
63
+ Nyle.cr.set_source(pattern)
64
+ Nyle.cr.paint
65
+ @running_count += 1
66
+ end
67
+
68
+ # Need not only :pointer_motion but also :button_press and :button_release
69
+ self.add_events([:button_press_mask,
70
+ :button_release_mask,
71
+ :pointer_motion_mask])
72
+
73
+ # Signal handler for mouse position
74
+ self.signal_connect(:motion_notify_event) do |widget, event|
75
+ Nyle.module_eval {
76
+ _set_mouse_pos(event.x, event.y)
77
+ }
78
+ false
79
+ end
80
+ end
81
+
82
+ # When single screen, create frame to show self
83
+ def show_all(title = DEFAULT_TITLE)
84
+ f = Nyle::Frame.new(@width, @height, {title: title})
85
+ f.set_current(self)
86
+
87
+ # Workaround for Segmentation Fault when ImageSureface instance create by using RGBA32 data at Screen.initialize
88
+ f.override_background_color(:normal, Gdk::RGBA::new(Cairo::Color.parse(@bgcolor).r,
89
+ Cairo::Color.parse(@bgcolor).g,
90
+ Cairo::Color.parse(@bgcolor).b, 1.0))
91
+ f.show_all
92
+ f
93
+ end
94
+
95
+ # Abstract methods to be overriden
96
+ private def update ; end
97
+ private def draw ; end
98
+ private def suspend ; end
99
+ private def resume ; end
100
+ end
101
+
102
+ end
103
+
104
+
105
+ # [TODO] :draw counter (for waiting, sleeping, idling)
106
+
@@ -0,0 +1,3 @@
1
+ module Nyle
2
+ VERSION = "0.5.2"
3
+ end
data/lib/nyle.rb ADDED
@@ -0,0 +1,345 @@
1
+
2
+ =begin
3
+ 'Nyle'
4
+ minimal graphics framework using Ruby/GTK3 and Cairo
5
+
6
+ Copyright (c) 2018 Koki Kitamura
7
+ Released under the MIT license
8
+ https://opensource.org/licenses/mit-license.php
9
+ =end
10
+
11
+ require 'gtk3'
12
+ require 'rbconfig'
13
+
14
+ require 'nyle/version'
15
+ require 'nyle/frame'
16
+ require 'nyle/screen'
17
+
18
+ module Nyle
19
+ class Error < StandardError; end
20
+
21
+ DEFAULT_WIDTH = 640
22
+ DEFAULT_HEIGHT = 480
23
+ DEFAULT_TITLE = 'Nyle'
24
+
25
+ @__cr = nil
26
+ @__screen_width = DEFAULT_WIDTH
27
+ @__screen_height = DEFAULT_HEIGHT
28
+ @__mouse_x = 0
29
+ @__mouse_y = 0
30
+ @__mouse_down = {}
31
+ @__mouse_down_last = {}
32
+ @__mouse_press = {}
33
+ @__mouse_release = {}
34
+ @__key_down = {}
35
+ @__key_down_last = {}
36
+ @__key_press = {}
37
+ @__key_release = {}
38
+ @__mask_control = false
39
+ @__mask_shift = false
40
+
41
+ @__os = (
42
+ host_os = RbConfig::CONFIG['host_os']
43
+ case host_os
44
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
45
+ :windows
46
+ when /darwin|mac os/
47
+ :mac
48
+ when /linux/
49
+ :linux
50
+ else
51
+ :unknown
52
+ end
53
+ )
54
+
55
+
56
+ # Singleton class
57
+ class << self
58
+ # private methods for classes in module 'Nyle'
59
+ private def _set_cr(cr)
60
+ @__cr = cr
61
+ end
62
+
63
+ private def _set_screen_size(w, h)
64
+ @__screen_width = w
65
+ @__screen_height = h
66
+ end
67
+
68
+ private def _set_mouse_pos(x, y)
69
+ @__mouse_x = x
70
+ @__mouse_y = y
71
+ end
72
+
73
+ private def _set_mouse_down(button, status)
74
+ @__mouse_down[button] = status
75
+ end
76
+
77
+ private def _set_key_down(keyval, status)
78
+ @__key_down[keyval] = status
79
+ end
80
+
81
+ private def _update_mouse_state
82
+ @__mouse_down.each_key do |k|
83
+ change = @__mouse_down[k] ^ @__mouse_down_last[k] # Get change of mouse press status (XOR)
84
+ press = change & @__mouse_down[k] # Detect change to press from release
85
+ release = change & !@__mouse_down[k] # Detect change to release from press
86
+ @__mouse_press[k] = press # Set mouse_press status
87
+ @__mouse_release[k] = release # Set mouse_release status
88
+ @__mouse_down_last[k] = @__mouse_down[k]
89
+ end
90
+ end
91
+
92
+ private def _update_key_state
93
+ @__key_down.each_key do |k|
94
+ change = @__key_down[k] ^ @__key_down_last[k] # Get change of key press status (XOR)
95
+ press = change & @__key_down[k] # Detect change to press from release
96
+ release = change & !@__key_down[k] # Detect change to release from press
97
+ @__key_press[k] = press # Set key_press status
98
+ @__key_release[k] = release # Set key_release status
99
+ @__key_down_last[k] = @__key_down[k]
100
+
101
+ if @__key_down[Gdk::Keyval::KEY_Control_L] or
102
+ @__key_down[Gdk::Keyval::KEY_Control_R]
103
+ @__mask_control = true # Set true to mask_control status
104
+ else
105
+ @__mask_control = false # Set false to mask_control status
106
+ end
107
+
108
+ if @__key_down[Gdk::Keyval::KEY_Shift_L] or
109
+ @__key_down[Gdk::Keyval::KEY_Shift_R]
110
+ @__mask_shift = true # Set true to mask_shift status
111
+ else
112
+ @__mask_shift = false # Set false to mask_shift status
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+
119
+ # module functions for user
120
+ # (need module_eval{} statement to use including Nyle)
121
+ module_function def cr ; Nyle.module_eval{ @__cr } ; end
122
+ module_function def screen_width ; Nyle.module_eval{ @__screen_width } ; end
123
+ module_function def screen_height ; Nyle.module_eval{ @__screen_height } ; end
124
+ module_function def mouse_x ; Nyle.module_eval{ @__mouse_x } ; end
125
+ module_function def mouse_y ; Nyle.module_eval{ @__mouse_y } ; end
126
+ module_function def mouse_down?(button) ; Nyle.module_eval{ @__mouse_down [button] == true } ; end
127
+ module_function def mouse_press?(button) ; Nyle.module_eval{ @__mouse_press [button] == true } ; end
128
+ module_function def mouse_release?(button) ; Nyle.module_eval{ @__mouse_release[button] == true } ; end
129
+ module_function def key_down?(keyval) ; Nyle.module_eval{ @__key_down [keyval] == true } ; end
130
+ module_function def key_press?(keyval) ; Nyle.module_eval{ @__key_press [keyval] == true } ; end
131
+ module_function def key_release?(keyval) ; Nyle.module_eval{ @__key_release [keyval] == true } ; end
132
+ module_function def mask_control? ; Nyle.module_eval{ @__mask_control } ; end
133
+ module_function def mask_shift? ; Nyle.module_eval{ @__mask_shift } ; end
134
+ module_function def os ; Nyle.module_eval{ @__os } ; end
135
+
136
+ module_function def draw_line(x1, y1, x2, y2, weight: 2, cap: :BUTT, color: :BLACK, a: 1.0)
137
+ cr = Nyle.module_eval{ @__cr }
138
+ cr.save do
139
+ cr.line_width = weight
140
+ cr.line_cap = cap
141
+ if a == 1.0
142
+ cr.set_source_color(color)
143
+ else
144
+ cr.set_source_rgba(Cairo::Color.parse(color).r,
145
+ Cairo::Color.parse(color).g,
146
+ Cairo::Color.parse(color).b, a)
147
+ end
148
+ cr.move_to(x1, y1)
149
+ cr.line_to(x2, y2)
150
+ cr.stroke
151
+ end
152
+ end
153
+
154
+ module_function def draw_rect(x, y, w, h, weight: 2, cap: :BUTT, color: :BLACK, round: 0, fill: false, a: 1.0)
155
+ cr = Nyle.module_eval{ @__cr }
156
+ cr.save do
157
+ cr.line_width = weight
158
+ cr.line_cap = cap
159
+ if a == 1.0
160
+ cr.set_source_color(color)
161
+ else
162
+ cr.set_source_rgba(Cairo::Color.parse(color).r,
163
+ Cairo::Color.parse(color).g,
164
+ Cairo::Color.parse(color).b, a)
165
+ end
166
+ if round
167
+ cr.rounded_rectangle(x, y, w, h, round, round)
168
+ else
169
+ cr.rectangle(x, y, w, h)
170
+ end
171
+ if fill
172
+ cr.fill
173
+ else
174
+ cr.stroke
175
+ end
176
+ end
177
+ end
178
+
179
+ module_function def draw_circle(x, y, r, weight: 2, color: :BLACK, fill: false, a: 1.0)
180
+ cr = Nyle.module_eval{ @__cr }
181
+ cr.save do
182
+ cr.line_width = weight
183
+ if a == 1.0
184
+ cr.set_source_color(color)
185
+ else
186
+ cr.set_source_rgba(Cairo::Color.parse(color).r,
187
+ Cairo::Color.parse(color).g,
188
+ Cairo::Color.parse(color).b, a)
189
+ end
190
+ cr.circle(x, y, r)
191
+ if fill
192
+ cr.fill
193
+ else
194
+ cr.stroke
195
+ end
196
+ end
197
+ end
198
+
199
+ module_function def draw_shape(points, weight: 2, cap: :BUTT, color: :BLACK, a: 1.0, close: false, fill: false)
200
+ cr = Nyle.module_eval{ @__cr }
201
+ cr.save do
202
+ cr.line_width = weight
203
+ cr.line_cap = cap
204
+ if a == 1.0
205
+ cr.set_source_color(color)
206
+ else
207
+ cr.set_source_rgba(Cairo::Color.parse(color).r,
208
+ Cairo::Color.parse(color).g,
209
+ Cairo::Color.parse(color).b, a)
210
+ end
211
+ vertex = points.dup
212
+ vertex << vertex.first if close # closed shape
213
+ vertex.each do |v|
214
+ cr.line_to(v[0], v[1])
215
+ end
216
+ if fill
217
+ cr.fill
218
+ else
219
+ cr.stroke
220
+ end
221
+ end
222
+ end
223
+
224
+ module_function def draw_text(x, y, str, size: 32, color: :BLACK, a: 1.0)
225
+ cr = Nyle.module_eval{ @__cr }
226
+ cr.save do
227
+ cr.select_font_face("+") # Temporaly use "+" [TODO] (Need to confirm font name)
228
+ cr.font_size = size
229
+ if a == 1.0
230
+ cr.set_source_color(color)
231
+ else
232
+ cr.set_source_rgba(Cairo::Color.parse(color).r,
233
+ Cairo::Color.parse(color).g,
234
+ Cairo::Color.parse(color).b, a)
235
+ end
236
+ cr.move_to(x, y)
237
+ cr.show_text(str)
238
+ end
239
+ end
240
+
241
+ module INNER
242
+ # for Nyle.load_image* methods
243
+ class << self
244
+ private def _load_image(filename, color_key: nil)
245
+ loaded = GdkPixbuf::Pixbuf.new(file: filename)
246
+ if color_key
247
+ # Set transparent color with given color (alpha = 0)
248
+ loaded.add_alpha(true,
249
+ Cairo::Color.parse(color_key).r * 255, # 0 - 255
250
+ Cairo::Color.parse(color_key).g * 255, # 0 - 255
251
+ Cairo::Color.parse(color_key).b * 255) # 0 - 255
252
+ else
253
+ # Not to transpare
254
+ loaded
255
+ end
256
+ end
257
+ end
258
+ end
259
+
260
+ module_function def load_image(filename, color_key: nil, sx: 1.0, sy: 1.0, cx: nil, cy: nil, cw: nil, ch: nil)
261
+ loaded = Nyle::INNER.module_eval{ _load_image(filename, color_key: color_key) }
262
+ if !(cx.nil? or cy.nil? or cw.nil? or ch.nil?)
263
+ loaded = loaded.subpixbuf(cx, cy, cw, ch)
264
+ end
265
+ loaded = loaded.scale(loaded.width * sx, loaded.height * sy)
266
+ end
267
+
268
+ module_function def load_image_tiles(filename, xcount, ycount, color_key: nil, sx: 1.0, sy: 1.0)
269
+ loaded = Nyle::INNER.module_eval{ _load_image(filename, color_key: color_key) }
270
+ xcount = 1 if xcount < 1
271
+ ycount = 1 if ycount < 1
272
+ cw = loaded.width / xcount
273
+ ch = loaded.height / ycount
274
+ tiles = []
275
+ for i in (0...xcount) do
276
+ line = []
277
+ for j in (0...ycount) do
278
+ line << loaded.subpixbuf(cw * i, ch * j, cw, ch).scale(cw * sx, ch * sy)
279
+ end
280
+ tiles << line
281
+ end
282
+ tiles
283
+ end
284
+
285
+ module_function def draw_image(x, y, pixbuf)
286
+ cr = Nyle.module_eval{ @__cr }
287
+ cr.save do
288
+ cr.set_source_pixbuf(pixbuf, x, y)
289
+ cr.paint
290
+ end
291
+ end
292
+
293
+ module_function def save_image(filename)
294
+ cr = Nyle.module_eval{ @__cr }
295
+ cr.target.write_to_png(filename)
296
+ end
297
+
298
+ module_function def translate(tx, ty)
299
+ cr = Nyle.module_eval{ @__cr }
300
+ cr.translate(tx, ty)
301
+ end
302
+
303
+ module_function def rotate(angle)
304
+ cr = Nyle.module_eval{ @__cr }
305
+ cr.rotate(angle)
306
+ end
307
+
308
+ module_function def scale(sx, sy)
309
+ cr = Nyle.module_eval{ @__cr }
310
+ cr.scale(sx, sy)
311
+ end
312
+
313
+ module_function def quit
314
+ Gtk.main_quit
315
+ end
316
+
317
+ end
318
+
319
+
320
+
321
+ if $0 == __FILE__
322
+ p Nyle
323
+ p Nyle.instance_methods
324
+ p Nyle.private_instance_methods
325
+ #p Nyle.private_methods
326
+ p Nyle.protected_methods
327
+ #p Nyle.public_methods
328
+ p Nyle.singleton_methods
329
+
330
+ p Nyle::Frame
331
+ p Nyle::Frame.instance_methods(false)
332
+ p Nyle::Frame.private_instance_methods(false)
333
+ p Nyle::Frame.singleton_methods(false)
334
+
335
+ p Nyle::Screen
336
+ p Nyle::Screen.instance_methods(false)
337
+ p Nyle::Screen.private_instance_methods(false)
338
+ p Nyle::Screen.singleton_methods(false)
339
+
340
+ p Nyle.os
341
+ end
342
+
343
+
344
+ # [TODO] Font name (draw_text)
345
+
data/nyle.gemspec ADDED
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nyle/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nyle"
8
+ spec.version = Nyle::VERSION
9
+ spec.authors = ["Koki Kitamura"]
10
+ spec.email = ["spool.kitamura@nifty.ne.jp"]
11
+
12
+ spec.summary = %q{minimal graphics framework using Ruby/GTK3 with Cairo}
13
+ spec.description = %q{'Nyle' is a minimal graphics framework using Ruby/GTK3 with Cairo}
14
+ spec.homepage = "https://github.com/spoolkitamura/nyle"
15
+ spec.license = "MIT"
16
+
17
+ ## Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ ## to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ #if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ #
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
+ #else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ #end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.17"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+
42
+ spec.add_runtime_dependency "gtk3", "~> 3.3.0", ">= 3.3.0"
43
+ spec.add_runtime_dependency "rsvg2", "~> 3.3.0", ">= 3.3.0"
44
+ end