Module: ZIsh

Included in:
JennCad::Primitives, JennCad::Primitives::Cube, JennCad::Primitives::Cylinder
Defined in:
lib/jenncad/shared/z_ish.rb

Instance Method Summary collapse

Instance Method Details

#czObject Also known as: center_z



15
16
17
18
19
20
21
22
# File 'lib/jenncad/shared/z_ish.rb', line 15

def cz
  if self.respond_to? :nc
    nc
  end
  @opts[:center_z] = true
  set_anchors_z
  self
end

#flip_axis(dir) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/jenncad/shared/z_ish.rb', line 25

def flip_axis(dir)
  case dir
    when :bottom
      nil
    when :top
      :z
    when :left, :right
      :x
    when :front, :back
      :y
  end
end

#flip_rotation(dir) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jenncad/shared/z_ish.rb', line 38

def flip_rotation(dir)
  case dir
    when :bottom
      {}
    when :left
      {y: 270}
    when :top
      {x: 180}
    when :right
      {y: 90}
    when :front
      {x: 90}
    when :back
      {x: 270}
  end
end

#set_anchors_zObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/jenncad/shared/z_ish.rb', line 3

def set_anchors_z
  if @opts[:center_z]
    set_anchor :bottom_face, z: -z/2.0
    set_anchor :top_face, z: z/2.0
    set_anchor :center, x: 0
  else
    set_anchor :bottom_face, z: 0
    set_anchor :top_face, z: z
    set_anchor :center,  zh: z
  end
end