diff options
| author | Tom Black <[email protected]> | 2020-02-01 21:54:21 -0600 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2021-04-12 11:30:39 -0500 |
| commit | 9328096b7db4375afe950156b78ee3a256c3e6ff (patch) | |
| tree | aafce78f039f5d984df3d898abf79abe5b838229 | |
| parent | 20ea36aefbbadea4619dfa1ce28d19e10f82045b (diff) | |
| download | ruby2d-9328096b7db4375afe950156b78ee3a256c3e6ff.tar.gz ruby2d-9328096b7db4375afe950156b78ee3a256c3e6ff.zip | |
Square `draw` method
| -rw-r--r-- | lib/ruby2d/square.rb | 17 |
1 files changed, 17 insertions, 0 deletions
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= |
