Object
Create a new Palette with the given name => color pairs.
# File lib/rubygame/color/palettes/palette.rb, line 23 def initialize( colors = {} ) @includes = [] @colors = {} colors.each_pair do |name, color| @colors[sanitize_name(name)] = color end end
Retrieve a color by name from this palette.
The name can be a Symbol or String. See sanitize_name.
If the color cannot be found in this palette, search each of the included palettes (recursively, depth-first, to a maximum depth of 5 levels).
If the color is not found in this palette or any included palettes, raise IndexError.
# File lib/rubygame/color/palettes/palette.rb, line 43 def []( name ) c = lookup( sanitize_name( name ) ) raise IndexError, "unknown color #{name}" unless c return c end
Store a color by name in this palette. See sanitize_name
# File lib/rubygame/color/palettes/palette.rb, line 50 def []=( name, color ) name = sanitize_name( name ) @colors[name] = color end
Include another palette in this one. If a color cannot be found in this palette, the included palette(s) will be searched. See also uninclude.
Has no effect if the palette is already included.
# File lib/rubygame/color/palettes/palette.rb, line 60 def include( palette ) @includes += [palette] unless @includes.include? palette end
Remove the other palette from this one, so that it won't be searched for missing colors anymore. Has no effect if the other palette hasn't been included.
# File lib/rubygame/color/palettes/palette.rb, line 67 def uninclude( palette ) @includes -= [palette] end
Generated with the Darkfish Rdoc Generator 2.