Class: JennCad::Primitives::Circle

Inherits:
Primitive show all
Includes:
CircleIsh
Defined in:
lib/jenncad/primitives/circle.rb

Direct Known Subclasses

Cylinder

Instance Attribute Summary collapse

Attributes inherited from Primitive

#dimensions

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

Methods included from CircleIsh

#auto_dn!, #handle_fn, #handle_radius_diameter, #radius, #set_anchors_2d

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) ⇒ Circle

Returns a new instance of Circle.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/jenncad/primitives/circle.rb', line 6

def initialize(args)
  if args.kind_of?(Array) && args[0].kind_of?(Hash)
    args = args.first
  end
  if args.kind_of? Array
    m = {}
    if args.last.kind_of? Hash
      m = args.last
    end
    args = [:d, :z].zip(args.flatten).to_h
    args.deep_merge!(m)
  end


  @opts = {
    d: 0,
    d1: nil,
    d2: nil,
    r1: nil,
    r2: nil,
    z: nil,
    r: 0,
    cz: false,
    margins: {
      r: 0,
      d: 0,
      z: 0,
    },
    fn: nil,
  }.deep_merge!(args)
  init(args)
  @dimensions = [:x, :y]
  handle_radius_diameter
  handle_fn
  set_anchors_2d
  @csize = Size.new(d: @opts[:d])
end

Instance Attribute Details

#dObject

Returns the value of attribute d.



5
6
7
# File 'lib/jenncad/primitives/circle.rb', line 5

def d
  @d
end

#fnObject

Returns the value of attribute fn.



5
6
7
# File 'lib/jenncad/primitives/circle.rb', line 5

def fn
  @fn
end

#rObject

Returns the value of attribute r.



5
6
7
# File 'lib/jenncad/primitives/circle.rb', line 5

def r
  @r
end

Instance Method Details

#openscad_paramsObject



44
45
46
47
48
49
50
# File 'lib/jenncad/primitives/circle.rb', line 44

def openscad_params
  res = {}
  [:d, :fn].each do |n|
    res[n] = self.send n
  end
  res
end