Class: Ruby2D::Image
Instance Attribute Summary collapse
-
#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.
-
#rotate ⇒ Object
Returns the value of attribute rotate.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes included from Renderable
Instance Method Summary collapse
-
#initialize(path, opts = {}) ⇒ Image
constructor
A new instance of Image.
Methods included from Renderable
#a, #a=, #add, #b, #b=, #colour, #colour=, #contains?, #g, #g=, #opacity, #opacity=, #r, #r=, #remove
Constructor Details
#initialize(path, opts = {}) ⇒ Image
Returns a new instance of Image.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ruby2d/image.rb', line 10 def initialize(path, opts = {}) unless File.exist? path raise Error, "Cannot find image file `#{path}`" end @path = path @x = opts[:x] || 0 @y = opts[:y] || 0 @z = opts[:z] || 0 @width = opts[:width] || nil @height = opts[:height] || nil @rotate = opts[:rotate] || 0 self.color = opts[:color] || 'white' self.opacity = opts[:opacity] if opts[:opacity] unless ext_init(@path) raise Error, "Image `#{@path}` cannot be created" end add end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 def data @data end |
#height ⇒ Object
Returns the value of attribute height.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 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 |
#rotate ⇒ Object
Returns the value of attribute rotate.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 def rotate @rotate end |
#width ⇒ Object
Returns the value of attribute width.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
8 9 10 |
# File 'lib/ruby2d/image.rb', line 8 def y @y end |