Class: CrystalScad::Square
- Inherits:
-
Primitive
- Object
- CrystalScadObject
- Primitive
- CrystalScad::Square
- Defined in:
- lib/crystalscad/CrystalScad.rb
Overview
2d primitives
Instance Attribute Summary
Attributes inherited from Primitive
Attributes inherited from CrystalScadObject
Instance Method Summary collapse
- #center_x ⇒ Object
- #center_xy ⇒ Object (also: #center)
- #center_y ⇒ Object
-
#initialize(*args) ⇒ Square
constructor
A new instance of Square.
- #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) ⇒ Square
Returns a new instance of Square.
170 171 172 173 174 175 176 177 178 |
# File 'lib/crystalscad/CrystalScad.rb', line 170 def initialize(*args) super(args) if args[0][:size].kind_of? Array @x,@y = args[0][:size].map{|l| l.to_f} else @x = args[0][:size].to_f @y = @x end end |
Instance Method Details
#center_x ⇒ Object
190 191 192 193 |
# File 'lib/crystalscad/CrystalScad.rb', line 190 def center_x @transformations << Translate.new({x:-@x/2}) self end |
#center_xy ⇒ Object Also known as: center
184 185 186 187 |
# File 'lib/crystalscad/CrystalScad.rb', line 184 def center_xy @transformations << Translate.new({x:-@x/2,y:-@y/2}) self end |
#center_y ⇒ Object
195 196 197 198 |
# File 'lib/crystalscad/CrystalScad.rb', line 195 def center_y @transformations << Translate.new({y:-@y/2}) self end |
#to_rubyscad ⇒ Object
180 181 182 |
# File 'lib/crystalscad/CrystalScad.rb', line 180 def to_rubyscad return RubyScadBridge.new.square(@args) end |