Class: Dedalus::Element

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

Direct Known Subclasses

Atom, Container, Layer, LayerStack, Molecule, Organism, Screen, Template

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Element

Returns a new instance of Element.



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

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.



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

def background_color
  @background_color
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#heightObject

raw width/height



17
18
19
# File 'lib/dedalus/elements.rb', line 17

def height
  @height
end

#height_percentObject

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



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

def height_percent
  @height_percent
end

#marginObject

Returns the value of attribute margin.



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

def margin
  @margin
end

#offsetObject

Returns the value of attribute offset.



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

def offset
  @offset
end

#paddingObject

Returns the value of attribute padding.



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

def padding
  @padding
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

#shownObject

Returns the value of attribute shown.



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

def shown
  @shown
end

#widthObject

raw width/height



17
18
19
# File 'lib/dedalus/elements.rb', line 17

def width
  @width
end

#width_percentObject

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



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

def width_percent
  @width_percent
end

#z_orderObject

index



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

def z_order
  @z_order
end

Instance Method Details

#big_fontObject



66
67
68
# File 'lib/dedalus/elements.rb', line 66

def big_font
  FontRepository.get_font(size: 24)
end

#code_fontObject



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

def code_font
  FontRepository.get_font('courier new', size: 20)
end

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



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/dedalus/elements.rb', line 37

def draw_bounding_box(origin:, dimensions:, color: Palette.gray)
  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



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

def font
  FontRepository.get_font(size: 20)
end

#huge_fontObject



70
71
72
# File 'lib/dedalus/elements.rb', line 70

def huge_font
  FontRepository.get_font(size: 120)
end

#record?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/dedalus/elements.rb', line 33

def record?
  false
end

#tiny_fontObject



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

def tiny_font
  FontRepository.get_font(size: 14)
end

#viewObject



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

def view
  Dedalus.active_view
end

#windowObject



74
75
76
# File 'lib/dedalus/elements.rb', line 74

def window
  view.window
end