Class: Fox::Canvas::ImageShape

Inherits:
Shape
  • Object
show all
Defined in:
lib/fox16/canvas.rb

Instance Attribute Summary collapse

Attributes inherited from Shape

#foreground, #selector, #target, #x, #y

Instance Method Summary collapse

Methods inherited from Shape

#apply_dc, #bounds, #deselect, #disable, #draggable=, #draggable?, #drawOutline, #enable, #enabled?, #hide, #hit?, #makeControlPoints, #move, #position, #resize, #select, #selected?, #show, #visible?

Constructor Details

#initialize(x, y, image) ⇒ ImageShape

Returns a new instance of ImageShape.



311
312
313
314
# File 'lib/fox16/canvas.rb', line 311

def initialize(x, y, image)
  super(x, y)
  @image = image
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



309
310
311
# File 'lib/fox16/canvas.rb', line 309

def image
  @image
end

Instance Method Details

#draw(dc) ⇒ Object



324
325
326
327
328
329
330
331
332
# File 'lib/fox16/canvas.rb', line 324

def draw(dc)
  apply_dc(dc) do
    if selected?
      dc.lineWidth = 5
      dc.drawRectangle(x - 3, y - 3, width + 5, height + 5)
    end
    dc.drawImage(image, x, y)
  end
end

#heightObject



320
321
322
# File 'lib/fox16/canvas.rb', line 320

def height
  @image.height
end

#widthObject



316
317
318
# File 'lib/fox16/canvas.rb', line 316

def width
  @image.width
end