Class: CrystalScad::Cube
- Inherits:
-
Primitive
- Object
- CrystalScadObject
- Primitive
- CrystalScad::Cube
- Defined in:
- lib/crystalscad/CrystalScad.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Attributes inherited from Primitive
Attributes inherited from CrystalScadObject
Instance Method Summary collapse
- #center ⇒ Object
- #center_x ⇒ Object
- #center_xy ⇒ Object
- #center_y ⇒ Object
- #center_z ⇒ Object
-
#initialize(*args) ⇒ Cube
constructor
A new instance of Cube.
- #to_rubyscad ⇒ Object
Methods inherited from Primitive
#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union
Methods inherited from CrystalScadObject
#save, #walk_tree, #walk_tree_classes
Constructor Details
#initialize(*args) ⇒ Cube
Returns a new instance of Cube.
97 98 99 100 |
# File 'lib/crystalscad/CrystalScad.rb', line 97 def initialize(*args) super(args) @x,@y,@z = args[0][:size].map{|l| l.to_f} end |
Instance Attribute Details
#x ⇒ Object
Returns the value of attribute x.
95 96 97 |
# File 'lib/crystalscad/CrystalScad.rb', line 95 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
95 96 97 |
# File 'lib/crystalscad/CrystalScad.rb', line 95 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
95 96 97 |
# File 'lib/crystalscad/CrystalScad.rb', line 95 def z @z end |
Instance Method Details
#center ⇒ Object
122 123 124 125 |
# File 'lib/crystalscad/CrystalScad.rb', line 122 def center @transformations << Translate.new({x:-@x/2,y:-@y/2,z:-@z/2}) self end |
#center_x ⇒ Object
107 108 109 110 |
# File 'lib/crystalscad/CrystalScad.rb', line 107 def center_x @transformations << Translate.new({x:-@x/2}) self end |
#center_xy ⇒ Object
102 103 104 105 |
# File 'lib/crystalscad/CrystalScad.rb', line 102 def center_xy @transformations << Translate.new({x:-@x/2,y:-@y/2}) self end |
#center_y ⇒ Object
112 113 114 115 |
# File 'lib/crystalscad/CrystalScad.rb', line 112 def center_y @transformations << Translate.new({y:-@y/2}) self end |
#center_z ⇒ Object
117 118 119 120 |
# File 'lib/crystalscad/CrystalScad.rb', line 117 def center_z @transformations << Translate.new({z:-@z/2}) self end |
#to_rubyscad ⇒ Object
127 128 129 |
# File 'lib/crystalscad/CrystalScad.rb', line 127 def to_rubyscad return RubyScadBridge.new.cube(@args) end |