summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorTom Black <[email protected]>2017-04-26 16:28:26 -0400
committerTom Black <[email protected]>2017-04-28 18:24:13 -0400
commit7bf37309d9c948df6947caa7d2b56d448a48e7cb (patch)
treea22357ab3b78fca7e6104640623dc6236ea2365f /lib
parent8d39db97fd82e99015d31fa38436fea6c1530a87 (diff)
downloadruby2d-7bf37309d9c948df6947caa7d2b56d448a48e7cb.tar.gz
ruby2d-7bf37309d9c948df6947caa7d2b56d448a48e7cb.zip
Opacity improvements
Adds opacity attribute reader for `Ruby2D::Color` and `Ruby2D::Color::Set`. Adds `opacity/=` method to renderable objects, a shortcut for `obj.color.opacity/=`.
Diffstat (limited to 'lib')
-rw-r--r--lib/ruby2d/color.rb8
-rw-r--r--lib/ruby2d/renderable.rb8
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/ruby2d/color.rb b/lib/ruby2d/color.rb
index e429e5c..1103c1b 100644
--- a/lib/ruby2d/color.rb
+++ b/lib/ruby2d/color.rb
@@ -15,7 +15,9 @@ module Ruby2D
def length
@colors.length
end
-
+
+ def opacity; @colors[0].opacity end
+
def opacity=(opacity)
@colors.each do |color|
color.opacity = opacity
@@ -95,7 +97,9 @@ module Ruby2D
Color.new(input)
end
end
-
+
+ def opacity; @a end
+
def opacity=(opacity)
@a = opacity
end
diff --git a/lib/ruby2d/renderable.rb b/lib/ruby2d/renderable.rb
index 3be6121..c8fac82 100644
--- a/lib/ruby2d/renderable.rb
+++ b/lib/ruby2d/renderable.rb
@@ -11,5 +11,13 @@ module Ruby2D
Application.remove(self)
end
end
+
+ def opacity
+ self.color.opacity
+ end
+
+ def opacity=(val)
+ self.color.opacity = val
+ end
end
end