smalruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby might be problematic. Click here for more details.

checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a7786456987e333a8081062fed59b8244ac24eb4
4
+ data.tar.gz: db0912885356cd0ef06f430b8427cf0c6f9a5729
5
+ SHA512:
6
+ metadata.gz: fc398eb11299c41a0c2df9b89a23dffdb5585a97d2b372355d202249f07269d91a0bd76f533a98574669541e3ed5388ccde94819fd4da7cb1b192e0f432ac425
7
+ data.tar.gz: 4c7dd3f654dd3f5f57a251d8c4f266ef1c279cbf83ccfe354f7142b80fdb1ea55fef4f74c837a69299723ef7791d45f60e8d32e8bd3d670efcd92c57f11c4b9c
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rake_tasks
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ spec/rspec
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+ *~
21
+ \#*\#
22
+ .\#*
23
+ assets/*.zip
24
+ /samples/_*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,39 @@
1
+ AllCops:
2
+ Excludes:
3
+ - tmp/**
4
+
5
+ MethodLength:
6
+ Enabled: false
7
+
8
+ ClassLength:
9
+ Enabled: false
10
+
11
+ Documentation:
12
+ Enabled: false
13
+
14
+ HandleExceptions:
15
+ Enabled: false
16
+
17
+ Blocks:
18
+ Enabled: false
19
+
20
+ FavorUnlessOverNegatedIf:
21
+ Enabled: false
22
+
23
+ IfUnlessModifier:
24
+ Enabled: false
25
+
26
+ RedundantReturn:
27
+ Enabled: false
28
+
29
+ AsciiComments:
30
+ Enabled: false
31
+
32
+ CaseEquality:
33
+ Enabled: false
34
+
35
+ SymbolName:
36
+ Enabled: false
37
+
38
+ StringLiterals:
39
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+
6
+ env:
7
+ AUDIODEV=null
8
+
9
+ before_install:
10
+ - sudo apt-get update -qq
11
+ - sudo apt-get install -qq libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev timidity libsdl-ttf2.0-dev libsdl-sge-dev fonts-horai-umefont fonts-ipafont
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in smalruby.gemspec
4
+ gemspec
5
+
6
+ if File.exist?(File.expand_path('~/work/dxruby_sdl/'))
7
+ gem 'dxruby_sdl', path: '~/work/dxruby_sdl/'
8
+ end
data/LEGAL ADDED
@@ -0,0 +1,11 @@
1
+ LEGAL NOTICE INFORMATION
2
+ ------------------------
3
+
4
+ All the files in this distribution are covered under either the
5
+ smalruby's license (see the file LICENSE) except some files
6
+ mentioned below.
7
+
8
+ assets/car1.png, assets/car2.png, assets/car3.png, assets/car4.png,
9
+ assets/cat1.png, assets/cat2.png, assets/cat3.png, assets/frog1.png:
10
+
11
+ This is downloaded from ICON HOIHOI http://iconhoihoi.oops.jp/.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kouji Takao
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # smalruby
2
+
3
+ smalruby is a 2D game development library. This is part of "Smalruby"
4
+ project that is a learning ruby programming environment for kids.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'smalruby'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```
17
+ $ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+
22
+ ```
23
+ $ gem install smalruby
24
+ ```
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'yard'
3
+ require "rspec/core/rake_task"
4
+
5
+ YARD::Rake::YardocTask.new do |t|
6
+ t.files = ['lib/**/*.rb']
7
+ t.options = []
8
+ end
9
+
10
+ if /darwin/ =~ RUBY_PLATFORM
11
+ task :spec do
12
+ sh "rsdl -S rspec #{ENV['SPEC_OPTS']} #{ENV['SPEC']}"
13
+ end
14
+
15
+ task :guard do
16
+ rspec_path = 'spec/rspec'
17
+ File.open(rspec_path, 'w') do |f|
18
+ f.write(<<-EOS)
19
+ #!/bin/sh
20
+ bundle exec rsdl -S rspec $@
21
+ EOS
22
+ end
23
+ chmod(0755, rspec_path)
24
+ begin
25
+ sh "bundle exec guard"
26
+ ensure
27
+ rm_rf(rspec_path)
28
+ end
29
+ end
30
+ else
31
+ RSpec::Core::RakeTask.new(:spec)
32
+ task :guard do
33
+ sh "bundle exec guard"
34
+ end
35
+ end
36
+
37
+ task :rubocop do
38
+ files = `git ls-files | grep -e '.rb$' | grep -v '^samples/'`
39
+ sh "rubocop #{files.split(/\s+/m).join(' ')}"
40
+ end
41
+
42
+ task :default => [:rubocop, :spec]
data/assets/car1.png ADDED
Binary file
data/assets/car2.png ADDED
Binary file
data/assets/car3.png ADDED
Binary file
data/assets/car4.png ADDED
Binary file
data/assets/cat1.png ADDED
Binary file
data/assets/cat2.png ADDED
Binary file
data/assets/cat3.png ADDED
Binary file
data/assets/frog1.png ADDED
Binary file
@@ -0,0 +1,87 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Smalruby
4
+ # お絵かきを表現するクラス
5
+ class Canvas < Character
6
+ def initialize(option = {})
7
+ opt = {
8
+ x: 0,
9
+ y: 0,
10
+ width: Window.width,
11
+ height: Window.height,
12
+ }.merge(option)
13
+ opt[:costume] = Image.new(opt[:width], opt[:height])
14
+ super(opt)
15
+ image.set_color_key([0, 0, 0])
16
+ end
17
+
18
+ # @!group ペン
19
+
20
+ def draw_font(option)
21
+ opt = {
22
+ x: 0,
23
+ y: 0,
24
+ string: "",
25
+ size: 32,
26
+ color: "white",
27
+ }.merge(option)
28
+ image.draw_font(opt[:x], opt[:y], opt[:string], Font.new(opt[:size]),
29
+ Color.smalruby_to_dxruby(opt[:color]))
30
+ end
31
+
32
+ def line(option)
33
+ opt = {
34
+ color: "white",
35
+ }.merge(verify_rect_option(option))
36
+ image.line(opt[:left], opt[:top], opt[:right], opt[:bottom],
37
+ Color.smalruby_to_dxruby(opt[:color]))
38
+ end
39
+
40
+ def box(option)
41
+ opt = {
42
+ color: "white",
43
+ }.merge(verify_rect_option(option))
44
+ image.box(opt[:left], opt[:top], opt[:right], opt[:bottom],
45
+ Color.smalruby_to_dxruby(opt[:color]))
46
+ end
47
+
48
+ def box_fill(option)
49
+ opt = {
50
+ color: "white",
51
+ }.merge(verify_rect_option(option))
52
+ image.box_fill(opt[:left], opt[:top], opt[:right], opt[:bottom],
53
+ Color.smalruby_to_dxruby(opt[:color]))
54
+ end
55
+
56
+ def circle(option)
57
+ opt = {
58
+ color: "white",
59
+ }.merge(option)
60
+ image.circle(opt[:x], opt[:y], opt[:r],
61
+ Color.smalruby_to_dxruby(opt[:color]))
62
+ end
63
+
64
+ def circle_fill(option)
65
+ opt = {
66
+ color: "white",
67
+ }.merge(option)
68
+ image.circle_fill(opt[:x], opt[:y], opt[:r],
69
+ Color.smalruby_to_dxruby(opt[:color]))
70
+ end
71
+
72
+ def_delegators :image, :clear
73
+
74
+ # @!endgroup
75
+
76
+ private
77
+
78
+ def verify_rect_option(option)
79
+ return {
80
+ left: option[:x1],
81
+ top: option[:y1],
82
+ right: option[:x2],
83
+ bottom: option[:y2],
84
+ }.merge(option)
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,204 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'forwardable'
3
+
4
+ module Smalruby
5
+ # キャラクターを表現するクラス
6
+ class Character < Sprite
7
+ extend Forwardable
8
+
9
+ attr_accessor :event_handlers
10
+ attr_accessor :threads
11
+
12
+ def initialize(option = {})
13
+ opt = {
14
+ x: 0,
15
+ y: 0,
16
+ costume: nil,
17
+ visible: true
18
+ }.merge(option)
19
+
20
+ # TODO: コスチュームの配列に対応する
21
+ if opt[:costume].is_a?(String)
22
+ opt[:costume] = Image.load(asset_path(opt[:costume]))
23
+ end
24
+ super(opt[:x], opt[:y], opt[:costume])
25
+
26
+ @event_handlers = {}
27
+ @threads = []
28
+
29
+ self.scale_x = 1.0
30
+ self.scale_y = 1.0
31
+ @vector = { x: 1, y: 0 }
32
+
33
+ [:visible].each do |k|
34
+ if opt.key?(k)
35
+ send("#{k}=", opt[k])
36
+ end
37
+ end
38
+
39
+ World.instance.objects << self
40
+ end
41
+
42
+ # @!group 動き
43
+
44
+ # ( )歩動かす
45
+ def move(val = 1)
46
+ self.x += @vector[:x] * val
47
+ self.y += @vector[:y] * val
48
+ end
49
+
50
+ # 振り返る
51
+ def turn
52
+ @vector[:x] *= -1
53
+ @vector[:y] *= -1
54
+ self.scale_x *= -1
55
+ end
56
+
57
+ # もし端に着いたら、跳ね返る
58
+ def turn_if_reach_wall
59
+ max_width = Window.width - image.width
60
+ if self.x < 0
61
+ self.x = 0
62
+ turn
63
+ elsif self.x >= max_width
64
+ self.x = max_width - 1
65
+ turn
66
+ end
67
+ end
68
+
69
+ # @!endgroup
70
+
71
+ # @!group 見た目
72
+
73
+ def say(message)
74
+ lines = message.to_s.lines.map { |l| l.scan(/.{1,10}/) }.flatten
75
+ font = Font.new(16)
76
+ width = lines.map { |l| font.get_width(l) }.max
77
+ height = lines.length * (font.size + 1)
78
+ frame_size = 3
79
+ margin_size = 3
80
+ image = Image.new(width + (frame_size + margin_size) * 2,
81
+ height + (frame_size + margin_size) * 2)
82
+ image.box_fill(0,
83
+ 0,
84
+ width + (frame_size + margin_size) * 2 - 1,
85
+ height + (frame_size + margin_size) * 2 - 1,
86
+ [125, 125, 125])
87
+ image.box_fill(frame_size,
88
+ frame_size,
89
+ width + (frame_size + margin_size) + margin_size - 1,
90
+ height + (frame_size + margin_size) + margin_size - 1,
91
+ [255, 255, 255])
92
+ image.draw_font(frame_size + margin_size,
93
+ frame_size + margin_size,
94
+ lines.join("\n"), font, [0, 0, 0])
95
+ @balloon = Sprite.new(self.x, self.y, image)
96
+ end
97
+
98
+ # @!endgroup
99
+
100
+ # @!group 調べる
101
+
102
+ def distance(x, y)
103
+ res = Math.sqrt((self.x + center_x - x).abs**2 +
104
+ (self.y + center_y - y).abs**2).to_i
105
+ return res
106
+ end
107
+
108
+ # @!endgroup
109
+
110
+ def draw
111
+ if @balloon
112
+ @balloon.x = self.x + image.width / 2
113
+ if @balloon.x < 0
114
+ @balloon.x = 0
115
+ elsif @balloon.x + @balloon.image.width >= Window.width
116
+ @balloon.x = Window.width - @balloon.image.width
117
+ end
118
+ @balloon.y = self.y - @balloon.image.height
119
+ if @balloon.y < 0
120
+ @balloon.y = 0
121
+ elsif @balloon.y + @balloon.image.height >= Window.height
122
+ @balloon.y = Window.height - @balloon.image.height
123
+ end
124
+ @balloon.draw
125
+ end
126
+ if self.x < 0
127
+ self.x = 0
128
+ elsif self.x + image.width >= Window.width
129
+ self.x = Window.width - image.width
130
+ end
131
+ if self.y < 0
132
+ self.y = 0
133
+ elsif self.y + image.height >= Window.height
134
+ self.y = Window.height - image.height
135
+ end
136
+ super
137
+ end
138
+
139
+ def on(event, *options, &block)
140
+ event = event.to_sym
141
+ @event_handlers[event] ||= []
142
+ h = EventHandler.new(self, options, &block)
143
+ @event_handlers[event] << h
144
+
145
+ if Smalruby.started?
146
+ @threads << h.call
147
+ end
148
+ end
149
+
150
+ def start
151
+ @event_handlers[:start].try(:each) do |h|
152
+ @threads << h.call
153
+ end
154
+ end
155
+
156
+ def key_down(keys)
157
+ @event_handlers[:key_down].try(:each) do |h|
158
+ if h.options.length > 0 && !h.options.any? { |k| keys.include?(k) }
159
+ next
160
+ end
161
+ @threads << h.call
162
+ end
163
+ end
164
+
165
+ def key_push(keys)
166
+ @event_handlers[:key_push].try(:each) do |h|
167
+ if h.options.length > 0 && !h.options.any? { |k| keys.include?(k) }
168
+ next
169
+ end
170
+ @threads << h.call
171
+ end
172
+ end
173
+
174
+ def click(buttons)
175
+ @event_handlers[:click].try(:each) do |h|
176
+ if h.options.length > 0 && !h.options.any? { |b| buttons.include?(b) }
177
+ next
178
+ end
179
+ @threads << h.call(Input.mouse_pos_x, Input.mouse_pos_y)
180
+ end
181
+ end
182
+
183
+ def alive?
184
+ return @threads.any?(&:alive?)
185
+ end
186
+
187
+ def join
188
+ @threads.each(&:join)
189
+ end
190
+
191
+ def loop(&block)
192
+ Kernel.loop do
193
+ yield
194
+ Smalruby.await
195
+ end
196
+ end
197
+
198
+ private
199
+
200
+ def asset_path(name)
201
+ return File.expand_path("../../../assets/#{name}", __FILE__)
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,162 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module Smalruby
4
+ # 色を表現するモジュール
5
+ module Color
6
+ # 名前から色のコードへの変換テーブル
7
+ # 参照: http://www.colordic.org/
8
+ NAME_TO_CODE = {
9
+ "black" => [0x00, 0x00, 0x00],
10
+ "dimgray" => [0x69, 0x69, 0x69],
11
+ "gray" => [0x80, 0x80, 0x80],
12
+ "darkgray" => [0xa9, 0xa9, 0xa9],
13
+ "silver" => [0xc0, 0xc0, 0xc0],
14
+ "lightgrey" => [0xd3, 0xd3, 0xd3],
15
+ "gainsboro" => [0xdc, 0xdc, 0xdc],
16
+ "whitesmoke" => [0xf5, 0xf5, 0xf5],
17
+ "white" => [0xff, 0xff, 0xff],
18
+ "snow" => [0xff, 0xfa, 0xfa],
19
+ "ghostwhite" => [0xf8, 0xf8, 0xff],
20
+ "floralwhite" => [0xff, 0xfa, 0xf0],
21
+ "linen" => [0xfa, 0xf0, 0xe6],
22
+ "antiquewhite" => [0xfa, 0xeb, 0xd7],
23
+ "papayawhip" => [0xff, 0xef, 0xd5],
24
+ "blanchedalmond" => [0xff, 0xeb, 0xcd],
25
+ "bisque" => [0xff, 0xe4, 0xc4],
26
+ "moccasin" => [0xff, 0xe4, 0xb5],
27
+ "navajowhite" => [0xff, 0xde, 0xad],
28
+ "peachpuff" => [0xff, 0xda, 0xb9],
29
+ "mistyrose" => [0xff, 0xe4, 0xe1],
30
+ "lavenderblush" => [0xff, 0xf0, 0xf5],
31
+ "seashell" => [0xff, 0xf5, 0xee],
32
+ "oldlace" => [0xfd, 0xf5, 0xe6],
33
+ "ivory" => [0xff, 0xff, 0xf0],
34
+ "honeydew" => [0xf0, 0xff, 0xf0],
35
+ "mintcream" => [0xf5, 0xff, 0xfa],
36
+ "azure" => [0xf0, 0xff, 0xff],
37
+ "aliceblue" => [0xf0, 0xf8, 0xff],
38
+ "lavender" => [0xe6, 0xe6, 0xfa],
39
+ "lightsteelblue" => [0xb0, 0xc4, 0xde],
40
+ "lightslategray" => [0x77, 0x88, 0x99],
41
+ "slategray" => [0x70, 0x80, 0x90],
42
+ "steelblue" => [0x46, 0x82, 0xb4],
43
+ "royalblue" => [0x41, 0x69, 0xe1],
44
+ "midnightblue" => [0x19, 0x19, 0x70],
45
+ "navy" => [0x00, 0x00, 0x80],
46
+ "darkblue" => [0x00, 0x00, 0x8b],
47
+ "mediumblue" => [0x00, 0x00, 0xcd],
48
+ "blue" => [0x00, 0x00, 0xff],
49
+ "dodgerblue" => [0x1e, 0x90, 0xff],
50
+ "cornflowerblue" => [0x64, 0x95, 0xed],
51
+ "deepskyblue" => [0x00, 0xbf, 0xff],
52
+ "lightskyblue" => [0x87, 0xce, 0xfa],
53
+ "skyblue" => [0x87, 0xce, 0xeb],
54
+ "lightblue" => [0xad, 0xd8, 0xe6],
55
+ "powderblue" => [0xb0, 0xe0, 0xe6],
56
+ "paleturquoise" => [0xaf, 0xee, 0xee],
57
+ "lightcyan" => [0xe0, 0xff, 0xff],
58
+ "cyan" => [0x00, 0xff, 0xff],
59
+ "aqua" => [0x00, 0xff, 0xff],
60
+ "turquoise" => [0x40, 0xe0, 0xd0],
61
+ "mediumturquoise" => [0x48, 0xd1, 0xcc],
62
+ "darkturquoise" => [0x00, 0xce, 0xd1],
63
+ "lightseagreen" => [0x20, 0xb2, 0xaa],
64
+ "cadetblue" => [0x5f, 0x9e, 0xa0],
65
+ "darkcyan" => [0x00, 0x8b, 0x8b],
66
+ "teal" => [0x00, 0x80, 0x80],
67
+ "darkslategray" => [0x2f, 0x4f, 0x4f],
68
+ "darkgreen" => [0x00, 0x64, 0x00],
69
+ "green" => [0x00, 0x80, 0x00],
70
+ "forestgreen" => [0x22, 0x8b, 0x22],
71
+ "seagreen" => [0x2e, 0x8b, 0x57],
72
+ "mediumseagreen" => [0x3c, 0xb3, 0x71],
73
+ "mediumaquamarine" => [0x66, 0xcd, 0xaa],
74
+ "darkseagreen" => [0x8f, 0xbc, 0x8f],
75
+ "aquamarine" => [0x7f, 0xff, 0xd4],
76
+ "palegreen" => [0x98, 0xfb, 0x98],
77
+ "lightgreen" => [0x90, 0xee, 0x90],
78
+ "springgreen" => [0x00, 0xff, 0x7f],
79
+ "mediumspringgreen" => [0x00, 0xfa, 0x9a],
80
+ "lawngreen" => [0x7c, 0xfc, 0x00],
81
+ "chartreuse" => [0x7f, 0xff, 0x00],
82
+ "greenyellow" => [0xad, 0xff, 0x2f],
83
+ "lime" => [0x00, 0xff, 0x00],
84
+ "limegreen" => [0x32, 0xcd, 0x32],
85
+ "yellowgreen" => [0x9a, 0xcd, 0x32],
86
+ "darkolivegreen" => [0x55, 0x6b, 0x2f],
87
+ "olivedrab" => [0x6b, 0x8e, 0x23],
88
+ "olive" => [0x80, 0x80, 0x00],
89
+ "darkkhaki" => [0xbd, 0xb7, 0x6b],
90
+ "palegoldenrod" => [0xee, 0xe8, 0xaa],
91
+ "cornsilk" => [0xff, 0xf8, 0xdc],
92
+ "beige" => [0xf5, 0xf5, 0xdc],
93
+ "lightyellow" => [0xff, 0xff, 0xe0],
94
+ "lightgoldenrodyellow" => [0xfa, 0xfa, 0xd2],
95
+ "lemonchiffon" => [0xff, 0xfa, 0xcd],
96
+ "wheat" => [0xf5, 0xde, 0xb3],
97
+ "burlywood" => [0xde, 0xb8, 0x87],
98
+ "tan" => [0xd2, 0xb4, 0x8c],
99
+ "khaki" => [0xf0, 0xe6, 0x8c],
100
+ "yellow" => [0xff, 0xff, 0x00],
101
+ "gold" => [0xff, 0xd7, 0x00],
102
+ "orange" => [0xff, 0xa5, 0x00],
103
+ "sandybrown" => [0xf4, 0xa4, 0x60],
104
+ "darkorange" => [0xff, 0x8c, 0x00],
105
+ "goldenrod" => [0xda, 0xa5, 0x20],
106
+ "peru" => [0xcd, 0x85, 0x3f],
107
+ "darkgoldenrod" => [0xb8, 0x86, 0x0b],
108
+ "chocolate" => [0xd2, 0x69, 0x1e],
109
+ "sienna" => [0xa0, 0x52, 0x2d],
110
+ "saddlebrown" => [0x8b, 0x45, 0x13],
111
+ "maroon" => [0x80, 0x00, 0x00],
112
+ "darkred" => [0x8b, 0x00, 0x00],
113
+ "brown" => [0xa5, 0x2a, 0x2a],
114
+ "firebrick" => [0xb2, 0x22, 0x22],
115
+ "indianred" => [0xcd, 0x5c, 0x5c],
116
+ "rosybrown" => [0xbc, 0x8f, 0x8f],
117
+ "darksalmon" => [0xe9, 0x96, 0x7a],
118
+ "lightcoral" => [0xf0, 0x80, 0x80],
119
+ "salmon" => [0xfa, 0x80, 0x72],
120
+ "lightsalmon" => [0xff, 0xa0, 0x7a],
121
+ "coral" => [0xff, 0x7f, 0x50],
122
+ "tomato" => [0xff, 0x63, 0x47],
123
+ "orangered" => [0xff, 0x45, 0x00],
124
+ "red" => [0xff, 0x00, 0x00],
125
+ "crimson" => [0xdc, 0x14, 0x3c],
126
+ "mediumvioletred" => [0xc7, 0x15, 0x85],
127
+ "deeppink" => [0xff, 0x14, 0x93],
128
+ "hotpink" => [0xff, 0x69, 0xb4],
129
+ "palevioletred" => [0xdb, 0x70, 0x93],
130
+ "pink" => [0xff, 0xc0, 0xcb],
131
+ "lightpink" => [0xff, 0xb6, 0xc1],
132
+ "thistle" => [0xd8, 0xbf, 0xd8],
133
+ "magenta" => [0xff, 0x00, 0xff],
134
+ "fuchsia" => [0xff, 0x00, 0xff],
135
+ "violet" => [0xee, 0x82, 0xee],
136
+ "plum" => [0xdd, 0xa0, 0xdd],
137
+ "orchid" => [0xda, 0x70, 0xd6],
138
+ "mediumorchid" => [0xba, 0x55, 0xd3],
139
+ "darkorchid" => [0x99, 0x32, 0xcc],
140
+ "darkviolet" => [0x94, 0x00, 0xd3],
141
+ "darkmagenta" => [0x8b, 0x00, 0x8b],
142
+ "purple" => [0x80, 0x00, 0x80],
143
+ "indigo" => [0x4b, 0x00, 0x82],
144
+ "darkslateblue" => [0x48, 0x3d, 0x8b],
145
+ "blueviolet" => [0x8a, 0x2b, 0xe2],
146
+ "mediumpurple" => [0x93, 0x70, 0xdb],
147
+ "slateblue" => [0x6a, 0x5a, 0xcd],
148
+ "mediumslateblue" => [0x7b, 0x68, 0xee],
149
+ }
150
+
151
+ module_function
152
+
153
+ # Smalrubyの色名からDXRubyの色コードに変換する
154
+ def smalruby_to_dxruby(color)
155
+ if color.is_a?(String)
156
+ return NAME_TO_CODE[color.downcase]
157
+ else
158
+ return color
159
+ end
160
+ end
161
+ end
162
+ end