Class: RIImage

Inherits:
Object
  • Object
show all
Defined in:
lib/RIUI/RIImage.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RIImage

Returns a new instance of RIImage.



5
6
7
8
9
10
11
12
# File 'lib/RIUI/RIImage.rb', line 5

def initialize(opts={})
  @path = opts[:image] || "/"
  @x = opts[:x] || 0
  @y = opts[:y] || 0
  @width = opts[:width] || 0
  @height = opts[:height] || 0
  @image = Image.new(path: @path, x: @x, y: @y, width: @width, height: @height)
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def color
  @color
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def height
  @height
end

#imageObject

Returns the value of attribute image.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def image
  @image
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def width
  @width
end

#xObject

Returns the value of attribute x.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def x
  @x
end

#yObject

Returns the value of attribute y.



3
4
5
# File 'lib/RIUI/RIImage.rb', line 3

def y
  @y
end

Instance Method Details

#setColor(opts = [:color]) ⇒ Object



19
20
21
# File 'lib/RIUI/RIImage.rb', line 19

def setColor(opts=[:color])
  @image.color = opts[:color]
end

#setSize(opts = [:width, :height]) ⇒ Object



13
14
15
16
17
18
# File 'lib/RIUI/RIImage.rb', line 13

def setSize(opts=[:width, :height])
  @width = opts[:width]
  @height = opts[:height]
  @image.remove
  @image = Image.new(path: @path, x: @x-@width/2, y: @y-@height/2, width: @width, height: @height)
end