Class: Dare::ImageTile

Inherits:
Object
  • Object
show all
Defined in:
lib/dare/image.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image = Image.new, x = 0, y = 0, width = 0, height = 0) ⇒ ImageTile

Returns a new instance of ImageTile.



202
203
204
205
206
207
208
# File 'lib/dare/image.rb', line 202

def initialize(image = Image.new, x = 0, y = 0, width = 0, height = 0)
  @image = image
  @x = x
  @y = y
  @width = width
  @height = height
end

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



201
202
203
# File 'lib/dare/image.rb', line 201

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



201
202
203
# File 'lib/dare/image.rb', line 201

def width
  @width
end

Instance Method Details

#draw(x = 0, y = 0, opts = {}) ⇒ Object



210
211
212
# File 'lib/dare/image.rb', line 210

def draw(x = 0, y = 0, opts = {})
  @image.draw_tile(x, y, opts.merge({sx: @x, sy: @y, swidth: @width, sheight: @height}))
end

#draw_rot(x = 0, y = 0, angle = 90, opts = {}) ⇒ Object



214
215
216
# File 'lib/dare/image.rb', line 214

def draw_rot(x = 0, y = 0, angle = 90, opts = {})
  @image.draw_tile_rot(x, y, angle, opts.merge({sx: @x, sy: @y, swidth: @width, sheight: @height}))
end