From 9328096b7db4375afe950156b78ee3a256c3e6ff Mon Sep 17 00:00:00 2001 From: Tom Black Date: Sat, 1 Feb 2020 21:54:21 -0600 Subject: Square `draw` method --- lib/ruby2d/square.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/ruby2d/square.rb b/lib/ruby2d/square.rb index 500381a..d890bb1 100644 --- a/lib/ruby2d/square.rb +++ b/lib/ruby2d/square.rb @@ -21,6 +21,23 @@ module Ruby2D self.width = self.height = @size = s end + + def self.draw(x: 0, y: 0, z: 0, size: 100) + + @width = @height = @size = size || 100 + + @x = opts[:x] || 0 + @y = opts[:y] || 0 + @z = opts[:z] || 0 + + self.color = opts[:color] || 'white' + self.opacity = opts[:opacity] if opts[:opacity] + update_coords(@x, @y, @size, @size) + + ext_draw(x, y, c) + end + + # Make the inherited width and height attribute accessors private private :width=, :height= -- cgit v1.2.3