Class: Dedalus::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/dedalus/elements.rb

Direct Known Subclasses

Atom, Molecule, Organism, Screen, Template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Element

Returns a new instance of Element.



30
31
32
# File 'lib/dedalus/elements.rb', line 30

def initialize(attrs={})
  attrs.each { |(k,v)| instance_variable_set(:"@#{k}",v) } unless attrs.nil?
end

Instance Attribute Details

#background_colorObject

Returns the value of attribute background_color.



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

def background_color
  @background_color
end

#heightObject

raw width/height



25
26
27
# File 'lib/dedalus/elements.rb', line 25

def height
  @height
end

#height_percentObject

in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively)



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

def height_percent
  @height_percent
end

#marginObject

Returns the value of attribute margin.



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

def margin
  @margin
end

#paddingObject

Returns the value of attribute padding.



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

def padding
  @padding
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

#widthObject

raw width/height



25
26
27
# File 'lib/dedalus/elements.rb', line 25

def width
  @width
end

#width_percentObject

in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively)



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

def width_percent
  @width_percent
end

Instance Method Details

#big_fontObject



55
56
57
# File 'lib/dedalus/elements.rb', line 55

def big_font
  FontRepository.get_font(size: 36)
end

#draw_bounding_box(origin:, dimensions:, color: Palette.gray) ⇒ Object

, highlight: false)



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/dedalus/elements.rb', line 34

def draw_bounding_box(origin:, dimensions:, color: Palette.gray) #, highlight: false)
  x,y = *origin
  w,h = *dimensions

  raise "Invalid color #{color} given to #{self.class.name} for bounding box" unless color.is_a?(Dedalus::Color)

  c = color.to_gosu
  window.draw_quad(x,y,c,
                   x,y+h,c,
                   x+w,y,c,
                   x+w,y+h,c,ZOrder::Background)
end

#fontObject



51
52
53
# File 'lib/dedalus/elements.rb', line 51

def font
  FontRepository.get_font(size: 20)
end

#huge_fontObject



59
60
61
# File 'lib/dedalus/elements.rb', line 59

def huge_font
  FontRepository.get_font(size: 120)
end

#viewObject



47
48
49
# File 'lib/dedalus/elements.rb', line 47

def view
  Dedalus.active_view
end

#windowObject



63
64
65
# File 'lib/dedalus/elements.rb', line 63

def window
  view.window
end