Module: CircleIsh

Included in:
JennCad::Primitives::Circle, JennCad::Primitives::Slot
Defined in:
lib/jenncad/shared/circle_ish.rb

Instance Method Summary collapse

Instance Method Details

#auto_dn!Object



30
31
32
33
34
35
36
37
# File 'lib/jenncad/shared/circle_ish.rb', line 30

def auto_dn!
  case @d
    when (16..)
      @fn = (@d*4).ceil
    else
      @fn = 64
  end
end

#handle_fnObject



21
22
23
24
25
26
27
28
# File 'lib/jenncad/shared/circle_ish.rb', line 21

def handle_fn
  case @opts[:fn]
    when nil, 0
      $fn = auto_dn!
    else
      @fn = @opts[:fn]
  end
end

#handle_radius_diameterObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/jenncad/shared/circle_ish.rb', line 39

def handle_radius_diameter
  case @opts[:d]
  when 0, nil
    @r = @opts[:r].to_d + @opts[:margins][:r].to_d
    @d = @r * 2.0
  else
    @d = @opts[:d].to_d + @opts[:margins][:d].to_d
    @r = @d / 2.0
  end

  case @opts[:d1]
  when 0, nil
  else
    @d1 = @opts[:d1].to_d + @opts[:margins][:d].to_d
    @d2 = @opts[:d2].to_d + @opts[:margins][:d].to_d
  end

  case @opts[:r1]
  when 0, nil
  else
    @d1 = 2 * @opts[:r1].to_d + @opts[:margins][:d].to_d
    @d2 = 2 * @opts[:r2].to_d + @opts[:margins][:d].to_d
  end
end

#radiusObject



3
4
5
6
7
8
9
# File 'lib/jenncad/shared/circle_ish.rb', line 3

def radius
  if @opts[:d]
    @opts[:d].to_d / 2.0
  else
    @opts[:r].to_d
  end
end

#set_anchors_2dObject



11
12
13
14
15
16
17
18
19
# File 'lib/jenncad/shared/circle_ish.rb', line 11

def set_anchors_2d
  @anchors = {} # reset anchors
  rad = radius
  # Similar to cube
  set_anchor :left, x: -rad
  set_anchor :right, x: rad
  set_anchor :top, y: rad
  set_anchor :bottom, y: -rad
end