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.



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

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.



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

def background_color
  @background_color
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#heightObject

raw width/height



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

def height
  @height
end

#height_percentObject

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



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

def height_percent
  @height_percent
end

#marginObject

Returns the value of attribute margin.



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

def margin
  @margin
end

#offsetObject

Returns the value of attribute offset.



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

def offset
  @offset
end

#paddingObject

Returns the value of attribute padding.



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

def padding
  @padding
end

#positionObject

Returns the value of attribute position.



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

def position
  @position
end

#widthObject

raw width/height



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

def width
  @width
end

#width_percentObject

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



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

def width_percent
  @width_percent
end

Instance Method Details

#big_fontObject



68
69
70
# File 'lib/dedalus/elements.rb', line 68

def big_font
  FontRepository.get_font(size: 24)
end

#code_fontObject



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

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

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



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

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



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

def font
  FontRepository.get_font(size: 20)
end

#huge_fontObject



72
73
74
# File 'lib/dedalus/elements.rb', line 72

def huge_font
  FontRepository.get_font(size: 120)
end

#record?Boolean

Returns:

  • (Boolean)


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

def record?
  false
end

#tiny_fontObject



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

def tiny_font
  FontRepository.get_font(size: 14)
end

#viewObject



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

def view
  Dedalus.active_view
end

#windowObject



76
77
78
# File 'lib/dedalus/elements.rb', line 76

def window
  view.window
end