Class: JennCad::Primitives::Text
- Defined in:
- lib/jenncad/primitives/text.rb
Instance Attribute Summary collapse
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#fn ⇒ Object
Returns the value of attribute fn.
-
#font ⇒ Object
Returns the value of attribute font.
-
#halign ⇒ Object
Returns the value of attribute halign.
-
#language ⇒ Object
Returns the value of attribute language.
-
#script ⇒ Object
Returns the value of attribute script.
-
#size ⇒ Object
Returns the value of attribute size.
-
#spacing ⇒ Object
Returns the value of attribute spacing.
-
#text ⇒ Object
Returns the value of attribute text.
-
#valign ⇒ Object
Returns the value of attribute valign.
Attributes inherited from Primitive
Attributes inherited from Thing
#anchors, #angle, #calc_h, #calc_x, #calc_y, #calc_z, #csize, #diameter, #name, #opts, #parent, #parts, #pos, #shape, #sits_on, #transformations, #x, #y
Instance Method Summary collapse
-
#initialize(args) ⇒ Text
constructor
A new instance of Text.
- #openscad_params ⇒ Object
- #parse_dir(dir) ⇒ Object
Methods inherited from Primitive
#feed_opts, #handle_diameter, #handle_margins
Methods inherited from Thing
#anchor, #at, #auto_color, #auto_color!, #auto_extrude, #calculate_center_rotation, #calculated_h, #children_list, #color, #color_or_fallback, #color_parse, #copy_anchor, #copy_anchors, #cut_to, #dbg, #debug?, #find_calculated_h, #fixate, #flip, #flipc, #get_children, #get_contents, #ghost, #has_explicit_color?, #hide, #hl, #inherit_color, #init, #is_2d?, #is_3d?, #mhx, #mhy, #mhz, #mirror, #mix, #miy, #miz, #modify_values, #modify_values!, #move, #movea, #moveai, #moveh, #movei, #multmatrix, #mx, #my, #mz, #on_top_of, #only, #only_color?, #openscad, #openscad_modifier, #option, #parse_xyz_shortcuts, #radians, #referenced_z, #reset, #reset_last_move, #rotate, #rotate_around, #rx, #ry, #rz, #scale, #set_anchor, #set_anchor_from, #set_auto_color, #set_auto_color_for_children, #set_flag, #set_heights_for_auto_extrude, #set_option, #set_parent, #skew, #to_mod, #top_of, #transform, #unset_flag, #z, #z=, #z_margin
Constructor Details
#initialize(args) ⇒ Text
Returns a new instance of Text.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/jenncad/primitives/text.rb', line 5 def initialize(args) @text = args[:text] @size = args[:size] @font = args[:font] @valign = args[:valign] @halign = args[:halign] @spacing = args[:spacing] @script = args[:script] @direction = parse_dir(args[:dir] || args[:direction]) case @direction when "btt", "ttb" @valign ||= :top @halign ||= :left end @language = args[:language] @fn = args[:fn] init(args) end |
Instance Attribute Details
#direction ⇒ Object
Returns the value of attribute direction.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def direction @direction end |
#fn ⇒ Object
Returns the value of attribute fn.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def fn @fn end |
#font ⇒ Object
Returns the value of attribute font.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def font @font end |
#halign ⇒ Object
Returns the value of attribute halign.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def halign @halign end |
#language ⇒ Object
Returns the value of attribute language.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def language @language end |
#script ⇒ Object
Returns the value of attribute script.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def script @script end |
#size ⇒ Object
Returns the value of attribute size.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def size @size end |
#spacing ⇒ Object
Returns the value of attribute spacing.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def spacing @spacing end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def text @text end |
#valign ⇒ Object
Returns the value of attribute valign.
3 4 5 |
# File 'lib/jenncad/primitives/text.rb', line 3 def valign @valign end |
Instance Method Details
#openscad_params ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/jenncad/primitives/text.rb', line 41 def openscad_params res = {} [:text, :font, :valign, :halign, :size, :spacing, :script, :direction, :language, :fn].each do |n| res[n] = self.send n end res end |
#parse_dir(dir) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jenncad/primitives/text.rb', line 26 def parse_dir(dir) case dir.to_s when "x", "ltr" "ltr" when "-x", "xn", "nx", "xi", "rtl" "rtl" when "y", "btt" "btt" when "-y", "yn", "ny", "yi", "ttb" "ttb" else nil end end |