Module: Salamander::Drawing::Circle

Defined in:
lib/salamander/drawing/circle.rb

Instance Method Summary collapse

Instance Method Details

#arc(rotation, radius) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/salamander/drawing/circle.rb', line 3

def arc(rotation, radius)
  direction = (rotation > 0.degrees) ? :right : :left
  
  # Enter the center of the arc's circle
  turn direction  # Turn towards the center point
  move radius     # Move to the center point
  turn :around    # Face the first endpoint of the arc
 
  # Draw the arc
  x, y = position
  if rotation > 0.degrees
    canvas.arc(x, y, radius, angle, angle+rotation, color)
  else
    canvas.arc(x, y, radius, angle+rotation, angle, color)
  end
  
  # Move to the opposite side of the arc
  turn rotation.degrees
  move radius
  turn direction
end

#circle(radius) ⇒ Object



25
26
27
28
# File 'lib/salamander/drawing/circle.rb', line 25

def circle(radius)
  x, y = position
  canvas.circle(x, y, radius, color)
end