From 2f194a30ff9d6cdf281d35c3b7b93182436650d2 Mon Sep 17 00:00:00 2001 From: Tom Black Date: Mon, 26 Apr 2021 19:33:08 -0500 Subject: Direct draw images --- lib/ruby2d/image.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib') diff --git a/lib/ruby2d/image.rb b/lib/ruby2d/image.rb index 67ce1b1..ecaeb53 100644 --- a/lib/ruby2d/image.rb +++ b/lib/ruby2d/image.rb @@ -26,5 +26,28 @@ module Ruby2D add end + def draw(opts = {}) + opts[:width] = opts[:width] || @width + opts[:height] = opts[:height] || @height + opts[:rotate] = opts[:rotate] || @rotate + unless opts[:color] + opts[:color] = [1.0, 1.0, 1.0, 1.0] + end + + self.class.ext_draw([ + self, opts[:x], opts[:y], opts[:width], opts[:height], opts[:rotate], + opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3] + ]) + end + + private + + def render + self.class.ext_draw([ + self, @x, @y, @width, @height, @rotate, + @color.r, @color.g, @color.b, @color.a + ]) + end + end end -- cgit v1.2.3