Class: Ruby2D::Image
- Inherits:
-
Object
- Object
- Ruby2D::Image
- Defined in:
- lib/ruby2d/image.rb,
ext/ruby2d/ruby2d-opal.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#data ⇒ Object
Returns the value of attribute data.
-
#height ⇒ Object
Returns the value of attribute height.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #add ⇒ Object
- #init(path) ⇒ Object
-
#initialize(x, y, path) ⇒ Image
constructor
A new instance of Image.
- #remove ⇒ Object
Constructor Details
#initialize(x, y, path) ⇒ Image
Returns a new instance of Image.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ruby2d/image.rb', line 9 def initialize(x, y, path) # TODO: Check if file exists # `File.exists?` is not available in MRuby # Ideally would do: # unless File.exists? path # raise Error, "Cannot find image file `#{path}`" # end @type_id = 3 @x, @y, @path = x, y, path @color = Color.new([1, 1, 1, 1]) init(path) add end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
7 8 9 |
# File 'lib/ruby2d/image.rb', line 7 def color @color end |
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/ruby2d/image.rb', line 6 def data @data end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/ruby2d/image.rb', line 6 def height @height end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/ruby2d/image.rb', line 7 def path @path end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/ruby2d/image.rb', line 6 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
6 7 8 |
# File 'lib/ruby2d/image.rb', line 6 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
6 7 8 |
# File 'lib/ruby2d/image.rb', line 6 def y @y end |
Instance Method Details
#add ⇒ Object
29 30 31 32 33 |
# File 'lib/ruby2d/image.rb', line 29 def add if Module.const_defined? :DSL Application.add(self) end end |
#init(path) ⇒ Object
135 136 137 |
# File 'ext/ruby2d/ruby2d-opal.rb', line 135 def init(path) `#{self}.data = S2D.CreateImage(path);` end |
#remove ⇒ Object
35 36 37 38 39 |
# File 'lib/ruby2d/image.rb', line 35 def remove if Module.const_defined? :DSL Application.remove(self) end end |