Class: CrystalScad::Primitive
- Inherits:
-
CrystalScadObject
- Object
- CrystalScadObject
- CrystalScad::Primitive
- Defined in:
- lib/crystalscad/Primitive.rb
Direct Known Subclasses
AdvancedPrimitive, Assembly, CSGModelling, CSGModifier, Circle, Cube, Cylinder, Import, Polygon, Polyhedron, Render, Sphere, Square
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
Attributes inherited from CrystalScadObject
Instance Method Summary collapse
- #mirror(args) ⇒ Object
- #rotate(args) ⇒ Object
- #rotate_around(point, args) ⇒ Object
- #scale(args) ⇒ Object
-
#transform(obj) ⇒ Object
copies the transformation of obj to self.
- #translate(args) ⇒ Object
- #union(args) ⇒ Object
Methods inherited from CrystalScadObject
#initialize, #save, #to_rubyscad, #walk_tree, #walk_tree_classes
Constructor Details
This class inherits a constructor from CrystalScad::CrystalScadObject
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
3 4 5 |
# File 'lib/crystalscad/Primitive.rb', line 3 def children @children end |
Instance Method Details
#mirror(args) ⇒ Object
33 34 35 36 37 |
# File 'lib/crystalscad/Primitive.rb', line 33 def mirror(args) @transformations ||= [] @transformations << Mirror.new(args) self end |
#rotate(args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/crystalscad/Primitive.rb', line 5 def rotate(args) # always make sure we have a z parameter; otherwise RubyScad will produce a 2-dimensional output # which can result in openscad weirdness if args[:z] == nil args[:z] = 0 end @transformations ||= [] @transformations << Rotate.new(args) self end |
#rotate_around(point, args) ⇒ Object
16 17 18 19 |
# File 'lib/crystalscad/Primitive.rb', line 16 def rotate_around(point,args) x,y,z= point.x, point.y, point.z self.translate(x:-x,y:-y,z:-z).rotate(args).translate(x:x,y:y,z:z) end |
#scale(args) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/crystalscad/Primitive.rb', line 39 def scale(args) if args.kind_of? Numeric or args.kind_of? Array args = {v:args} end @transformations ||= [] @transformations << Scale.new(args) self end |
#transform(obj) ⇒ Object
copies the transformation of obj to self
49 50 51 52 53 |
# File 'lib/crystalscad/Primitive.rb', line 49 def transform(obj) @transformations ||= [] @transformations += obj.transformations self end |