rubygame 2.2.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CREDITS +60 -0
  2. data/LICENSE +504 -0
  3. data/NEWS +201 -0
  4. data/README +139 -0
  5. data/ROADMAP +43 -0
  6. data/Rakefile +409 -0
  7. data/doc/extended_readme.rdoc +49 -0
  8. data/doc/getting_started.rdoc +47 -0
  9. data/doc/macosx_install.rdoc +70 -0
  10. data/doc/windows_install.rdoc +127 -0
  11. data/ext/rubygame/MANIFEST +25 -0
  12. data/ext/rubygame/rubygame_core.so +0 -0
  13. data/ext/rubygame/rubygame_event.c +644 -0
  14. data/ext/rubygame/rubygame_event.h +48 -0
  15. data/ext/rubygame/rubygame_event.obj +0 -0
  16. data/ext/rubygame/rubygame_gfx.c +942 -0
  17. data/ext/rubygame/rubygame_gfx.h +101 -0
  18. data/ext/rubygame/rubygame_gfx.obj +0 -0
  19. data/ext/rubygame/rubygame_gfx.so +0 -0
  20. data/ext/rubygame/rubygame_gl.c +154 -0
  21. data/ext/rubygame/rubygame_gl.h +32 -0
  22. data/ext/rubygame/rubygame_gl.obj +0 -0
  23. data/ext/rubygame/rubygame_image.c +108 -0
  24. data/ext/rubygame/rubygame_image.h +41 -0
  25. data/ext/rubygame/rubygame_image.obj +0 -0
  26. data/ext/rubygame/rubygame_image.so +0 -0
  27. data/ext/rubygame/rubygame_joystick.c +247 -0
  28. data/ext/rubygame/rubygame_joystick.h +41 -0
  29. data/ext/rubygame/rubygame_joystick.obj +0 -0
  30. data/ext/rubygame/rubygame_main.c +155 -0
  31. data/ext/rubygame/rubygame_main.h +33 -0
  32. data/ext/rubygame/rubygame_main.obj +0 -0
  33. data/ext/rubygame/rubygame_mixer.c +764 -0
  34. data/ext/rubygame/rubygame_mixer.h +62 -0
  35. data/ext/rubygame/rubygame_mixer.obj +0 -0
  36. data/ext/rubygame/rubygame_mixer.so +0 -0
  37. data/ext/rubygame/rubygame_screen.c +448 -0
  38. data/ext/rubygame/rubygame_screen.h +43 -0
  39. data/ext/rubygame/rubygame_screen.obj +0 -0
  40. data/ext/rubygame/rubygame_shared.c +209 -0
  41. data/ext/rubygame/rubygame_shared.h +60 -0
  42. data/ext/rubygame/rubygame_shared.obj +0 -0
  43. data/ext/rubygame/rubygame_surface.c +1147 -0
  44. data/ext/rubygame/rubygame_surface.h +62 -0
  45. data/ext/rubygame/rubygame_surface.obj +0 -0
  46. data/ext/rubygame/rubygame_time.c +183 -0
  47. data/ext/rubygame/rubygame_time.h +32 -0
  48. data/ext/rubygame/rubygame_time.obj +0 -0
  49. data/ext/rubygame/rubygame_ttf.c +599 -0
  50. data/ext/rubygame/rubygame_ttf.h +69 -0
  51. data/ext/rubygame/rubygame_ttf.obj +0 -0
  52. data/ext/rubygame/rubygame_ttf.so +0 -0
  53. data/lib/rubygame.rb +41 -0
  54. data/lib/rubygame/MANIFEST +12 -0
  55. data/lib/rubygame/clock.rb +128 -0
  56. data/lib/rubygame/color.rb +79 -0
  57. data/lib/rubygame/color/models/base.rb +106 -0
  58. data/lib/rubygame/color/models/hsl.rb +153 -0
  59. data/lib/rubygame/color/models/hsv.rb +149 -0
  60. data/lib/rubygame/color/models/rgb.rb +78 -0
  61. data/lib/rubygame/color/palettes/css.rb +49 -0
  62. data/lib/rubygame/color/palettes/palette.rb +100 -0
  63. data/lib/rubygame/color/palettes/x11.rb +177 -0
  64. data/lib/rubygame/constants.rb +238 -0
  65. data/lib/rubygame/event.rb +313 -0
  66. data/lib/rubygame/ftor.rb +370 -0
  67. data/lib/rubygame/hotspot.rb +265 -0
  68. data/lib/rubygame/keyconstants.rb +237 -0
  69. data/lib/rubygame/mediabag.rb +94 -0
  70. data/lib/rubygame/queue.rb +288 -0
  71. data/lib/rubygame/rect.rb +612 -0
  72. data/lib/rubygame/sfont.rb +223 -0
  73. data/lib/rubygame/sprite.rb +511 -0
  74. data/samples/FreeSans.ttf +0 -0
  75. data/samples/GPL.txt +340 -0
  76. data/samples/README +40 -0
  77. data/samples/chimp.bmp +0 -0
  78. data/samples/chimp.rb +313 -0
  79. data/samples/demo_gl.rb +151 -0
  80. data/samples/demo_gl_tex.rb +197 -0
  81. data/samples/demo_music.rb +75 -0
  82. data/samples/demo_rubygame.rb +284 -0
  83. data/samples/demo_sfont.rb +52 -0
  84. data/samples/demo_ttf.rb +193 -0
  85. data/samples/demo_utf8.rb +53 -0
  86. data/samples/fist.bmp +0 -0
  87. data/samples/load_and_blit.rb +22 -0
  88. data/samples/panda.png +0 -0
  89. data/samples/punch.wav +0 -0
  90. data/samples/ruby.png +0 -0
  91. data/samples/song.ogg +0 -0
  92. data/samples/term16.png +0 -0
  93. data/samples/whiff.wav +0 -0
  94. metadata +152 -0
@@ -0,0 +1,153 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ require 'rubygame/color/models/base'
21
+
22
+ module Rubygame
23
+ module Color
24
+
25
+ # Represents color in the HSL (Hue, Saturation, Luminosity) color space.
26
+ class ColorHSL
27
+ include ColorBase
28
+
29
+ attr_reader :h, :s, :l, :a
30
+
31
+ # call-seq:
32
+ # new( [h,s,l,a] ) -> ColorHSL
33
+ # new( [h,s,l] ) -> ColorHSL
34
+ # new( color ) -> ColorHSL
35
+ #
36
+ # Create a new instance from an Array or an existing color
37
+ # (of any type). If the alpha (opacity) component is omitted
38
+ # from the array, full opacity will be used.
39
+ #
40
+ # All color components range from 0.0 to 1.0.
41
+ #
42
+ def initialize( color )
43
+ if color.kind_of?(Array)
44
+ @h, @s, @l, @a = color.collect { |i| i.to_f }
45
+ @a = 1.0 unless @a
46
+ elsif color.respond_to?(:to_rgba_ary)
47
+ @h, @s, @l, @a = self.class.rgba_to_hsla( *color.to_rgba_ary )
48
+ end
49
+ end
50
+
51
+ # Return an Array with the red, green, blue, and alpha components
52
+ # of the color (converting the color to the RGBA model first).
53
+ def to_rgba_ary
54
+ return self.class.hsla_to_rgba( @h, @s, @l, @a )
55
+ end
56
+
57
+ def to_s
58
+ "#<#{self.class} [#{@h}, #{@s}, #{@l}, #{@a}]>"
59
+ end
60
+ alias :inspect :to_s
61
+
62
+ class << self
63
+
64
+ def new_from_rgba( rgba )
65
+ new( rgba_to_hsla(*rgba) )
66
+ end
67
+
68
+ def new_from_sdl_rgba( rgba )
69
+ new_from_rgba( rgba.collect { |i| i / 255.0 } )
70
+ end
71
+
72
+ # Convert the red, green, blue, and alpha to the
73
+ # equivalent hue, saturation, luminosity, and alpha.
74
+ def rgba_to_hsla( r, g, b, a ) # :nodoc:
75
+ rgb_arr = [r, g, b]
76
+ max = rgb_arr.max
77
+ min = rgb_arr.min
78
+
79
+ # Calculate lightness.
80
+ l = (max + min) / 2.0
81
+
82
+ # Calculate saturation.
83
+ if l == 0.0 or max == min
84
+ s = 0
85
+ elsif 0 < l and l <= 0.5
86
+ s = (max - min) / (max + min)
87
+ else # l > 0.5
88
+ s = (max - min) / (2 - (max + min))
89
+ end
90
+
91
+ # Calculate hue.
92
+ if min == max
93
+ h = 0
94
+ # Undefined in this case, but set it to zero
95
+ elsif max == r and g >= b
96
+ h = (1.quo(6) * (g - b) / (max - min)) + 0
97
+ elsif max == r and g < b
98
+ h = (1.quo(6) * (g - b) / (max - min)) + 1.0
99
+ elsif max == g
100
+ h = (1.quo(6) * (b - r) / (max - min)) + 1.quo(3)
101
+ elsif max == b
102
+ h = (1.quo(6) * (r - g) / (max - min)) + 2.quo(3)
103
+ else
104
+ raise "Should never happen"
105
+ end
106
+
107
+ return [h,s,l,a]
108
+ end
109
+
110
+ # Convert the hue, saturation, luminosity, and alpha
111
+ # to the equivalent red, green, blue, and alpha.
112
+ def hsla_to_rgba( h, s, l, a ) # :nodoc:
113
+ # If the color is achromatic, return already with the lightness value for all components
114
+ if s == 0.0
115
+ return [l, l, l, a]
116
+ end
117
+
118
+ # Otherwise, we have to do the long, hard calculation
119
+
120
+ # q helper value
121
+ q = (l < 0.5) ? (l * (1.0 + s)) : (l + s - l * s)
122
+
123
+ # p helper value
124
+ p = (2.0 * l) - q
125
+
126
+ r = calculate_component( p, q, h + 1.quo(3) )
127
+ g = calculate_component( p, q, h )
128
+ b = calculate_component( p, q, h - 1.quo(3) )
129
+
130
+ return [r,g,b,a]
131
+ end
132
+
133
+ private
134
+
135
+ # Perform some arcane math to calculate a color component.
136
+ def calculate_component(p, q, tc) # :nodoc:
137
+ tc %= 1.0
138
+ if tc < 1.quo(6)
139
+ p + (q - p) * tc * 6.0
140
+ elsif tc < 0.5
141
+ q
142
+ elsif tc < 2.quo(3)
143
+ p + (q - p) * (2.quo(3) - tc) * 6.0
144
+ else
145
+ p
146
+ end
147
+ end
148
+
149
+ end
150
+
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,149 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ require 'rubygame/color/models/base'
21
+
22
+ module Rubygame
23
+ module Color
24
+
25
+ # Represents color in the HSV (Hue, Saturation, Value) color space.
26
+ class ColorHSV
27
+ include ColorBase
28
+
29
+ attr_reader :h, :s, :v, :a
30
+
31
+ # call-seq:
32
+ # new( [h,s,v,a] ) -> ColorHSV
33
+ # new( [h,s,v] ) -> ColorHSV
34
+ # new( color ) -> ColorHSV
35
+ #
36
+ # Create a new instance from an Array or an existing color
37
+ # (of any type). If the alpha (opacity) component is omitted
38
+ # from the array, full opacity will be used.
39
+ #
40
+ # All color components range from 0.0 to 1.0.
41
+ #
42
+ def initialize( color )
43
+ if color.kind_of?(Array)
44
+ @h, @s, @v, @a = color.collect { |i| i.to_f }
45
+ @a = 1.0 unless @a
46
+ elsif color.respond_to?(:to_rgba_ary)
47
+ @h, @s, @v, @a = self.class.rgba_to_hsva( *color.to_rgba_ary )
48
+ end
49
+ end
50
+
51
+ # Return an Array with the red, green, blue, and alpha components
52
+ # of the color (converting the color to the RGBA model first).
53
+ def to_rgba_ary
54
+ return self.class.hsva_to_rgba( @h, @s, @v, @a )
55
+ end
56
+
57
+ def to_s
58
+ "#<#{self.class} [#{@h}, #{@s}, #{@v}, #{@a}]>"
59
+ end
60
+ alias :inspect :to_s
61
+
62
+ class << self
63
+
64
+ def new_from_rgba( rgba )
65
+ new( rgba_to_hsva(*rgba) )
66
+ end
67
+
68
+ def new_from_sdl_rgba( rgba )
69
+ new_from_rgba( rgba.collect { |i| i / 255.0 } )
70
+ end
71
+
72
+ # Convert the red, green, blue, and alpha to the
73
+ # equivalent hue, saturation, value, and alpha.
74
+ def rgba_to_hsva( r, g, b, a ) # :nodoc:
75
+ rgb_arr = [r, g, b]
76
+ max = rgb_arr.max
77
+ min = rgb_arr.min
78
+
79
+ # Calculate hue.
80
+ if min == max
81
+ h = 0
82
+ # Undefined in this case, but set it to zero
83
+ elsif max == r and g >= b
84
+ h = (1.quo(6) * (g - b) / (max - min)) + 0
85
+ elsif max == r and g < b
86
+ h = (1.quo(6) * (g - b) / (max - min)) + 1.0
87
+ elsif max == g
88
+ h = (1.quo(6) * (b - r) / (max - min)) + 1.quo(3)
89
+ elsif max == b
90
+ h = (1.quo(6) * (r - g) / (max - min)) + 2.quo(3)
91
+ else
92
+ raise "Should never happen"
93
+ end
94
+
95
+ # Calulate value.
96
+ v = max
97
+
98
+ # Calculate saturation.
99
+ if max == 0.0
100
+ s = 0.0
101
+ else
102
+ s = 1.0 - (min / max)
103
+ end
104
+
105
+ return [h,s,v,a]
106
+ end
107
+
108
+ # Convert the hue, saturation, value, and alpha
109
+ # to the equivalent red, green, blue, and alpha.
110
+ def hsva_to_rgba( h, s, v, a ) # :nodoc:
111
+ # Determine what part of the "color hexagon" the hue is in.
112
+ hi = (h * 6).floor % 6
113
+
114
+ # Fractional part
115
+ f = (h * 6) - hi
116
+
117
+ # Helper values
118
+ p = v * (1.0 - s)
119
+ q = v * (1.0 - (f * s))
120
+ t = v * (1.0 - ((1.0 - f) * s))
121
+
122
+ # Finally calculate the rgb values
123
+ r, g, b = calculate_rgb(hi, v, p, t, q)
124
+
125
+ return [r, g, b, a]
126
+ end
127
+
128
+ private
129
+
130
+ def calculate_rgb(hi, v, p, t, q) # :nodoc:
131
+ case hi
132
+ when 0
133
+ return v, t, p
134
+ when 1
135
+ return q, v, p
136
+ when 2
137
+ return p, v, t
138
+ when 3
139
+ return p, q, v
140
+ when 4
141
+ return t, p, v
142
+ when 5
143
+ return v, p, q
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,78 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ require 'rubygame/color/models/base'
21
+
22
+ module Rubygame
23
+ module Color
24
+
25
+ # Represents color in the RGB (Red, Green, Blue) color space.
26
+ class ColorRGB
27
+ include ColorBase
28
+
29
+ attr_reader :r, :g, :b, :a
30
+
31
+ # call-seq:
32
+ # new( [r,g,b,a] ) -> ColorRGB
33
+ # new( [r,g,b] ) -> ColorRGB
34
+ # new( color ) -> ColorRGB
35
+ #
36
+ # Create a new instance from an Array or an existing color
37
+ # (of any type). If the alpha (opacity) component is omitted
38
+ # from the array, full opacity will be used.
39
+ #
40
+ # All color components range from 0.0 to 1.0.
41
+ #
42
+ def initialize( color )
43
+ if color.kind_of?(Array)
44
+ @r, @g, @b, @a = color.collect { |i| i.to_f }
45
+ @a = 1.0 unless @a
46
+ elsif color.respond_to?(:to_rgba_ary)
47
+ @r, @g, @b, @a = color.to_rgba_ary
48
+ end
49
+ end
50
+
51
+ # Converts the color to an RGBA array of integers
52
+ # ranging from 0 to 255, as SDL wants.
53
+ def to_sdl_rgba_ary
54
+ self.to_rgba_ary.collect { |i| (i * 255).to_i }
55
+ end
56
+
57
+ def to_rgba_ary
58
+ return [@r, @g, @b, @a]
59
+ end
60
+
61
+ def to_s
62
+ "#<#{self.class} [#{@r}, #{@g}, #{@b}, #{@a}]>"
63
+ end
64
+ alias :inspect :to_s
65
+
66
+ class << self
67
+ def new_from_rgba( rgba )
68
+ new( rgba )
69
+ end
70
+
71
+ def new_from_sdl_rgba( rgba )
72
+ new_from_rgba( rgba.collect { |i| i / 255.0 } )
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,49 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ require 'rubygame/color'
21
+ require 'rubygame/color/palettes/palette'
22
+ require 'rubygame/color/palettes/x11'
23
+
24
+ module Rubygame
25
+ module Color
26
+
27
+ # :enddoc:
28
+
29
+ # The CSS module contains all the colors in the CSS/HTML palette
30
+ # by symbol name, e.g. :alice_blue, :dark_olive_green, etc.
31
+ #
32
+ # NOTE: The CSS palette is identical to the X11 palette except for
33
+ # four colors: gray, green, maroon, and purple.
34
+ #
35
+ # Differences between CSS and X11 derived from
36
+ # http://en.wikipedia.org/wiki/X11_color_names
37
+ # as accessed on 2007-12-17
38
+ #
39
+ CSS = Palette.new({
40
+ :gray => ColorRGB.new( [0.50196, 0.50196, 0.50196] ),
41
+ :green => ColorRGB.new( [0.00000, 0.50196, 0.00000] ),
42
+ :maroon => ColorRGB.new( [0.50196, 0.00000, 0.00000] ),
43
+ :purple => ColorRGB.new( [0.50196, 0.00000, 0.50196] )
44
+ })
45
+
46
+ CSS.include X11
47
+
48
+ end
49
+ end
@@ -0,0 +1,100 @@
1
+ #--
2
+ # Rubygame -- Ruby code and bindings to SDL to facilitate game creation
3
+ # Copyright (C) 2007 John Croisant
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #++
19
+
20
+ class Rubygame::Color::Palette
21
+
22
+ # Create a new Palette with the given name => color pairs.
23
+ def initialize( colors = {} )
24
+ @includes = []
25
+
26
+ @colors = {}
27
+ colors.each_pair do |name, color|
28
+ @colors[sanitize_name(name)] = color
29
+ end
30
+ end
31
+
32
+ # Retrieve a color by name from this palette.
33
+ #
34
+ # The name can be a Symbol or String. See #sanitize_name.
35
+ #
36
+ # If the color cannot be found in this palette, search
37
+ # each of the #included palettes (recursively, depth-first,
38
+ # to a maximum depth of 5 levels).
39
+ #
40
+ # If the color is not found in this palette or any included
41
+ # palettes, raise IndexError.
42
+ #
43
+ def []( name )
44
+ c = lookup( sanitize_name( name ) )
45
+ raise IndexError, "unknown color #{name}" unless c
46
+ return c
47
+ end
48
+
49
+ # Store a color by name in this palette. See #sanitize_name
50
+ def []=( name, color )
51
+ name = sanitize_name( name )
52
+ @colors[name] = color
53
+ end
54
+
55
+ # Include another palette in this one. If a color cannot be
56
+ # found in this palette, the included palette(s) will be searched.
57
+ # See also #uninclude.
58
+ #
59
+ # Has no effect if the palette is already included.
60
+ def include( palette )
61
+ @includes += [palette] unless @includes.include? palette
62
+ end
63
+
64
+ # Remove the other palette from this one, so that it won't be
65
+ # searched for missing colors anymore. Has no effect if the
66
+ # other palette hasn't been #included.
67
+ def uninclude( palette )
68
+ @includes -= [palette]
69
+ end
70
+
71
+ protected
72
+
73
+ # Recursive color lookup
74
+ def lookup( name, max_depth=5 ) # :nodoc:
75
+ return nil if max_depth < 0
76
+
77
+ color = @colors[name]
78
+
79
+ unless color
80
+ @includes.each { |palette|
81
+ c = palette.lookup(name, max_depth-1)
82
+ color = c if c
83
+ }
84
+ end
85
+
86
+ return color
87
+ end
88
+
89
+ private
90
+
91
+ # Takes either a Symbol or a String, and converts it to a
92
+ # lowercase Symbol with spaces converted to underscores.
93
+ #
94
+ # E.g. "Alice Blue" and :ALICE_BLUE both become :alice_blue.
95
+ #
96
+ def sanitize_name( name )
97
+ name.to_s.gsub(' ','_').downcase.intern
98
+ end
99
+
100
+ end