-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnumber_tiles.rb
52 lines (43 loc) · 1.14 KB
/
number_tiles.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
#! /usr/local/bin/ruby
# encoding: utf-8
ocra = ENV['OCRA_EXECUTABLE'] rescue nil
if Gem.win_platform?
if ocra && !ocra.empty?
EXEC_PATH = File.dirname(File.expand_path(__FILE__)).gsub(/\//, '\\')
IMAGE_MAGICK_PATH = EXEC_PATH + "\\vendor\\ImageMagick-6.6.9-Q8"
ENV['PATH'] = IMAGE_MAGICK_PATH + ";" + ENV['PATH']
APP_PATH = File.dirname(File.expand_path(ocra))
else
require 'win32/api'
APP_PATH = File.dirname(File.expand_path(__FILE__))
end
else
APP_PATH = File.dirname(File.expand_path(__FILE__))
end
require 'gosu'
require 'opengl'
require 'rmagick'
input = ARGV[0]
ts = ARGV[1].to_i
class W < Gosu::Window
def initialize(input, ts)
@ts = ts
@input = input
super(48 * ts , 48 * ts, false)
@tiles = Gosu::Image.load_tiles(self, input, ts, ts, true)
self.caption = ARGV[0]
end
def draw
0.upto(255) do |n|
t = @tiles[n]
x = (n / 48) * 8
y = n % 48
t.draw(x * @ts, y * @ts, 0)
t = Gosu::Image.from_text($main, ":%3d" % [ n ], 'Arial', @ts)
t.draw((x+1) * @ts, y * @ts, 0)
#i.insert(t, (x+1) * ts, y * ts)
end
end
end
$main = W.new(input, ts)
$main.show