Class: Ruby2D::Texture
- Inherits:
-
Object
- Object
- Ruby2D::Texture
- Defined in:
- lib/ruby2d/texture.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#texture_id ⇒ Object
readonly
Returns the value of attribute texture_id.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #delete ⇒ Object
- #draw(coordinates, texture_coordinates, color) ⇒ Object
-
#initialize(pixel_data, width, height) ⇒ Texture
constructor
A new instance of Texture.
Constructor Details
#initialize(pixel_data, width, height) ⇒ Texture
Returns a new instance of Texture.
7 8 9 10 11 12 |
# File 'lib/ruby2d/texture.rb', line 7 def initialize(pixel_data, width, height) @pixel_data = pixel_data @width = width @height = height @texture_id = 0 end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
5 6 7 |
# File 'lib/ruby2d/texture.rb', line 5 def height @height end |
#texture_id ⇒ Object (readonly)
Returns the value of attribute texture_id.
5 6 7 |
# File 'lib/ruby2d/texture.rb', line 5 def texture_id @texture_id end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/ruby2d/texture.rb', line 5 def width @width end |
Instance Method Details
#delete ⇒ Object
24 25 26 |
# File 'lib/ruby2d/texture.rb', line 24 def delete ext_delete(@texture_id) end |
#draw(coordinates, texture_coordinates, color) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby2d/texture.rb', line 14 def draw(coordinates, texture_coordinates, color) if @texture_id == 0 @texture_id = ext_create(@pixel_data, @width, @height) @pixel_data = nil end color = [color.r, color.g, color.b, color.a] ext_draw(coordinates, texture_coordinates, color, @texture_id) end |