Class: Dedalus::Elements::Text
- Inherits:
-
Atom
- Object
- Dedalus::Element
- Atom
- Dedalus::Elements::Text
- Defined in:
- lib/dedalus/elements/text.rb
Instance Attribute Summary collapse
-
#padding ⇒ Object
Returns the value of attribute padding.
-
#scale ⇒ Object
Returns the value of attribute scale.
-
#text ⇒ Object
Returns the value of attribute text.
Attributes inherited from Dedalus::Element
#background_color, #color, #height_percent, #margin, #offset, #position, #shown, #width_percent, #z_order
Class Method Summary collapse
- .description ⇒ Object
-
.example_data ⇒ Object
sample data for the explorer...
Instance Method Summary collapse
Methods inherited from Dedalus::Element
#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #record?, #tiny_font, #view, #window
Constructor Details
This class inherits a constructor from Dedalus::Element
Instance Attribute Details
#padding ⇒ Object
Returns the value of attribute padding.
4 5 6 |
# File 'lib/dedalus/elements/text.rb', line 4 def padding @padding end |
#scale ⇒ Object
Returns the value of attribute scale.
4 5 6 |
# File 'lib/dedalus/elements/text.rb', line 4 def scale @scale end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/dedalus/elements/text.rb', line 4 def text @text end |
Class Method Details
.description ⇒ Object
38 39 40 |
# File 'lib/dedalus/elements/text.rb', line 38 def self.description "words" end |
.example_data ⇒ Object
sample data for the explorer...
34 35 36 |
# File 'lib/dedalus/elements/text.rb', line 34 def self.example_data { text: "Hello World" } end |
Instance Method Details
#dimensions ⇒ Object
29 30 31 |
# File 'lib/dedalus/elements/text.rb', line 29 def dimensions [ width, height ] end |
#height ⇒ Object
17 18 19 |
# File 'lib/dedalus/elements/text.rb', line 17 def height 2*padding + (font.height * scale) end |
#render ⇒ Object
6 7 8 9 10 11 |
# File 'lib/dedalus/elements/text.rb', line 6 def render(*) x,y = *position font.draw(text, x + padding, y + padding, z_order, self.scale, self.scale) # draw_bounding_box(origin: [x,y], dimensions: dimensions) end |
#width ⇒ Object
13 14 15 |
# File 'lib/dedalus/elements/text.rb', line 13 def width 2*padding + (font.text_width(text) * scale) end |