diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/color.rb | 5 | ||||
| -rw-r--r-- | lib/ruby2d/renderable.rb | 25 |
2 files changed, 21 insertions, 9 deletions
diff --git a/lib/ruby2d/color.rb b/lib/ruby2d/color.rb index 26d176f..296f228 100644 --- a/lib/ruby2d/color.rb +++ b/lib/ruby2d/color.rb @@ -26,7 +26,7 @@ module Ruby2D end end - attr_reader :r, :g, :b, :a + attr_accessor :r, :g, :b, :a # Based on clrs.cc @@colors = { @@ -128,4 +128,7 @@ module Ruby2D end end + + # Allow British English spelling of color + Colour = Color end diff --git a/lib/ruby2d/renderable.rb b/lib/ruby2d/renderable.rb index 6a6761d..18c7a78 100644 --- a/lib/ruby2d/renderable.rb +++ b/lib/ruby2d/renderable.rb @@ -23,14 +23,23 @@ module Ruby2D end end - def opacity - self.color.opacity - end - - def opacity=(val) - self.color.opacity = val - end - + # Allow shortcuts for setting color values + def r; self.color.r end + def g; self.color.g end + def b; self.color.b end + def a; self.color.a end + def r=(c); self.color.r = c end + def g=(c); self.color.g = c end + def b=(c); self.color.b = c end + def a=(c); self.color.a = c end + def opacity; self.color.opacity end + def opacity=(val); self.color.opacity = val end + + # Allow British English spelling of color + def colour; self.color end + def colour=(c); self.color = c end + + # Add a contains method stub def contains?(x, y) raise Error, "\`#contains?\` not implemented for this class yet" end |
