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.
-
#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.
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#position ⇒ Object
Returns the value of attribute position.
-
#width ⇒ Object
raw width/height.
-
#width_percent ⇒ Object
in % as 0.0-1.0 (hint to compositing engine for elements in columns/rows respectively).
Instance Method Summary collapse
- #big_font ⇒ Object
-
#draw_bounding_box(origin:, dimensions:, color: Palette.gray) ⇒ Object
, highlight: false).
- #font ⇒ Object
- #huge_font ⇒ Object
-
#initialize(attrs = {}) ⇒ Element
constructor
A new instance of Element.
- #view ⇒ Object
- #window ⇒ Object
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_color ⇒ Object
Returns the value of attribute background_color.
28 29 30 |
# File 'lib/dedalus/elements.rb', line 28 def background_color @background_color end |
#height ⇒ Object
raw width/height
25 26 27 |
# File 'lib/dedalus/elements.rb', line 25 def height @height end |
#height_percent ⇒ Object
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 |
#margin ⇒ Object
Returns the value of attribute margin.
27 28 29 |
# File 'lib/dedalus/elements.rb', line 27 def margin @margin end |
#padding ⇒ Object
Returns the value of attribute padding.
27 28 29 |
# File 'lib/dedalus/elements.rb', line 27 def padding @padding end |
#position ⇒ Object
Returns the value of attribute position.
19 20 21 |
# File 'lib/dedalus/elements.rb', line 19 def position @position end |
#width ⇒ Object
raw width/height
25 26 27 |
# File 'lib/dedalus/elements.rb', line 25 def width @width end |
#width_percent ⇒ Object
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_font ⇒ Object
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 |
#font ⇒ Object
51 52 53 |
# File 'lib/dedalus/elements.rb', line 51 def font FontRepository.get_font(size: 20) end |
#huge_font ⇒ Object
59 60 61 |
# File 'lib/dedalus/elements.rb', line 59 def huge_font FontRepository.get_font(size: 120) end |
#view ⇒ Object
47 48 49 |
# File 'lib/dedalus/elements.rb', line 47 def view Dedalus.active_view end |
#window ⇒ Object
63 64 65 |
# File 'lib/dedalus/elements.rb', line 63 def window view.window end |