Class: Dedalus::Element
- Inherits:
-
Object
- Object
- Dedalus::Element
- Defined in:
- lib/dedalus/elements.rb
Instance Attribute Summary collapse
-
#background_color ⇒ Object
Returns the value of attribute background_color.
-
#color ⇒ Object
Returns the value of attribute color.
-
#height ⇒ Object
raw width/height.
-
#height_percent ⇒ Object
in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively).
-
#margin ⇒ Object
Returns the value of attribute margin.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#position ⇒ Object
Returns the value of attribute position.
-
#shown ⇒ Object
Returns the value of attribute shown.
-
#width ⇒ Object
raw width/height.
-
#width_percent ⇒ Object
in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively).
-
#z_order ⇒ Object
index.
Instance Method Summary collapse
- #big_font ⇒ Object
- #code_font ⇒ Object
- #draw_bounding_box(origin:, dimensions:, color: Palette.gray) ⇒ Object
- #font ⇒ Object
- #huge_font ⇒ Object
-
#initialize(attrs = {}) ⇒ Element
constructor
A new instance of Element.
- #record? ⇒ Boolean
- #tiny_font ⇒ Object
- #view ⇒ Object
- #window ⇒ Object
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_color ⇒ Object
Returns the value of attribute background_color.
20 21 22 |
# File 'lib/dedalus/elements.rb', line 20 def background_color @background_color end |
#color ⇒ Object
Returns the value of attribute color.
20 21 22 |
# File 'lib/dedalus/elements.rb', line 20 def color @color end |
#height ⇒ Object
raw width/height
17 18 19 |
# File 'lib/dedalus/elements.rb', line 17 def height @height end |
#height_percent ⇒ Object
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 |
#margin ⇒ Object
Returns the value of attribute margin.
19 20 21 |
# File 'lib/dedalus/elements.rb', line 19 def margin @margin end |
#offset ⇒ Object
Returns the value of attribute offset.
11 12 13 |
# File 'lib/dedalus/elements.rb', line 11 def offset @offset end |
#padding ⇒ Object
Returns the value of attribute padding.
19 20 21 |
# File 'lib/dedalus/elements.rb', line 19 def padding @padding end |
#position ⇒ Object
Returns the value of attribute position.
11 12 13 |
# File 'lib/dedalus/elements.rb', line 11 def position @position end |
#shown ⇒ Object
Returns the value of attribute shown.
28 29 30 |
# File 'lib/dedalus/elements.rb', line 28 def shown @shown end |
#width ⇒ Object
raw width/height
17 18 19 |
# File 'lib/dedalus/elements.rb', line 17 def width @width end |
#width_percent ⇒ Object
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_order ⇒ Object
index
22 23 24 |
# File 'lib/dedalus/elements.rb', line 22 def z_order @z_order end |
Instance Method Details
#big_font ⇒ Object
66 67 68 |
# File 'lib/dedalus/elements.rb', line 66 def big_font FontRepository.get_font(size: 24) end |
#code_font ⇒ Object
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 |
#font ⇒ Object
62 63 64 |
# File 'lib/dedalus/elements.rb', line 62 def font FontRepository.get_font(size: 20) end |
#huge_font ⇒ Object
70 71 72 |
# File 'lib/dedalus/elements.rb', line 70 def huge_font FontRepository.get_font(size: 120) end |
#record? ⇒ Boolean
33 34 35 |
# File 'lib/dedalus/elements.rb', line 33 def record? false end |
#tiny_font ⇒ Object
54 55 56 |
# File 'lib/dedalus/elements.rb', line 54 def tiny_font FontRepository.get_font(size: 14) end |
#view ⇒ Object
50 51 52 |
# File 'lib/dedalus/elements.rb', line 50 def view Dedalus.active_view end |
#window ⇒ Object
74 75 76 |
# File 'lib/dedalus/elements.rb', line 74 def window view.window end |