summaryrefslogtreecommitdiffhomepage
path: root/test/testcard.rb
diff options
context:
space:
mode:
authorlstrzebinczyk <[email protected]>2017-03-21 14:20:54 +0100
committerTom Black <[email protected]>2017-03-28 22:23:34 -0400
commite5131435e9f78d37b8dd02be551299dac7f547d9 (patch)
treeb792765453421fd07f2463f4b3fbf9f72802933c /test/testcard.rb
parent79c50dab7f06e4ec288e79e61d0631fdf07b7264 (diff)
downloadruby2d-e5131435e9f78d37b8dd02be551299dac7f547d9.tar.gz
ruby2d-e5131435e9f78d37b8dd02be551299dac7f547d9.zip
implement Color#opacity=
Diffstat (limited to 'test/testcard.rb')
-rw-r--r--test/testcard.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/testcard.rb b/test/testcard.rb
index 44cc817..b25813b 100644
--- a/test/testcard.rb
+++ b/test/testcard.rb
@@ -175,6 +175,10 @@ pointer = Square.new(0, 0, 10, [1, 1, 1, 1])
pointer_outline = Square.new(0, 0, 18, [0, 1, 0, 0])
flash = 0
+# Updating opacity
+opacity_square = Square.new(500, 255, 50, ["red", "green", "blue", "yellow"])
+time_start = Time.now
+
on key: 'escape' do
close
end
@@ -202,6 +206,10 @@ update do
if (get :frames) % 20 == 0
fps.text = "FPS: #{(get :fps).round(3)}"
end
+
+ elapsed_time = Time.now - time_start
+ opacity = Math.sin(3 * elapsed_time.to_f).abs
+ opacity_square.color.opacity = opacity
end
show