class CrystalScad::Primitive

Attributes

children[RW]

Public Instance Methods

mirror(args) click to toggle source
# File lib/crystalscad/Primitive.rb, line 33
def mirror(args)
        @transformations ||= []                              
        @transformations << Mirror.new(args)         
        self                 
end
rotate(args) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source

copies the transformation of obj to self

# File lib/crystalscad/Primitive.rb, line 49
def transform(obj)
        @transformations ||= []
        @transformations += obj.transformations
        self
end
translate(args) click to toggle source
# File lib/crystalscad/Primitive.rb, line 21
def translate(args)
        @transformations ||= []                              
        @transformations << Translate.new(args)              
        self         
end
union(args) click to toggle source
# File lib/crystalscad/Primitive.rb, line 27
def union(args)
        @transformations ||= []                              
        @transformations << Union.new(args)          
        self                 
end