Class: Dedalus::Elements::Image

Inherits:
Atom show all
Defined in:
lib/dedalus/elements/image.rb

Direct Known Subclasses

Icon

Instance Attribute Summary collapse

Attributes inherited from Dedalus::Element

#background_color, #height_percent, #margin, #position, #width_percent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dedalus::Element

#big_font, #draw_bounding_box, #font, #huge_font, #initialize, #view, #window

Constructor Details

This class inherits a constructor from Dedalus::Element

Instance Attribute Details

#paddingObject

Returns the value of attribute padding.



12
13
14
# File 'lib/dedalus/elements/image.rb', line 12

def padding
  @padding
end

#pathObject

Returns the value of attribute path.



12
13
14
# File 'lib/dedalus/elements/image.rb', line 12

def path
  @path
end

Class Method Details

.descriptionObject



43
44
45
# File 'lib/dedalus/elements/image.rb', line 43

def self.description
  "an image"
end

.example_dataObject



39
40
41
# File 'lib/dedalus/elements/image.rb', line 39

def self.example_data
  { path: "media/icons/house.png" }
end

Instance Method Details

#dimensionsObject



27
28
29
# File 'lib/dedalus/elements/image.rb', line 27

def dimensions
  [ width, height ]
end

#heightObject



23
24
25
# File 'lib/dedalus/elements/image.rb', line 23

def height
  2*padding + (asset.height * scale)
end

#renderObject



14
15
16
17
# File 'lib/dedalus/elements/image.rb', line 14

def render
  x,y = *position
  asset.draw(x + padding, y + padding, ZOrder::Foreground, scale, scale)
end

#scaleObject



35
36
37
# File 'lib/dedalus/elements/image.rb', line 35

def scale
  @scale ||= 1.0
end

#widthObject



19
20
21
# File 'lib/dedalus/elements/image.rb', line 19

def width
  2*padding + (asset.width * scale)
end