Class: Dedalus::Elements::Text

Inherits:
Atom show all
Defined in:
lib/dedalus/elements/text.rb

Direct Known Subclasses

Heading, Paragraph

Instance Attribute Summary collapse

Attributes inherited from Dedalus::Element

#background_color, #color, #height_percent, #margin, #offset, #position, #shown, #width_percent, #z_order

Class Method Summary collapse

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

#paddingObject

Returns the value of attribute padding.



4
5
6
# File 'lib/dedalus/elements/text.rb', line 4

def padding
  @padding
end

#scaleObject

Returns the value of attribute scale.



4
5
6
# File 'lib/dedalus/elements/text.rb', line 4

def scale
  @scale
end

#textObject

Returns the value of attribute text.



4
5
6
# File 'lib/dedalus/elements/text.rb', line 4

def text
  @text
end

Class Method Details

.descriptionObject



38
39
40
# File 'lib/dedalus/elements/text.rb', line 38

def self.description
  "words"
end

.example_dataObject

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

#dimensionsObject



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

def dimensions
  [ width, height ]
end

#heightObject



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

def height
  2*padding + (font.height * scale)
end

#renderObject



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

#widthObject



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

def width
  2*padding + (font.text_width(text) * scale)
end