Class: Block
- Inherits:
-
Object
- Object
- Block
- Defined in:
- lib/block.rb
Overview
A simple block to be used in the figures and the glass
Copyright © 2011 Nikolay Nemshilov
Constant Summary collapse
- SIZE =
block size in pixels
20- FILE =
File.join(File.dirname(__FILE__), '..', 'media', 'block.png')
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #draw(x, y) ⇒ Object
-
#initialize(window, color) ⇒ Block
constructor
A new instance of Block.
Constructor Details
#initialize(window, color) ⇒ Block
Returns a new instance of Block.
12 13 14 15 |
# File 'lib/block.rb', line 12 def initialize(window, color) @@img ||= Image.new(window, FILE, true) @color = color end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
7 8 9 |
# File 'lib/block.rb', line 7 def color @color end |
#size ⇒ Object
Returns the value of attribute size.
7 8 9 |
# File 'lib/block.rb', line 7 def size @size end |
Instance Method Details
#draw(x, y) ⇒ Object
17 18 19 |
# File 'lib/block.rb', line 17 def draw(x, y) @@img.draw(x * SIZE, y * SIZE, 0, 1.0, 1.0, @color) end |