module Salamander::Drawing::Shapes

Public Instance Methods

polygon(sides, length) click to toggle source

Draws a regular polygon with ‘sides’ sides, each of length ‘length’

# File lib/salamander/drawing/shapes.rb, line 17
def polygon (sides, length)
  sides.times do
    line length
    turn (360.0/sides).degrees
  end
end
star(points, length) click to toggle source

Draws a star-like shape with number ‘points’ of points.

‘points’ must be odd.

# File lib/salamander/drawing/shapes.rb, line 8
def star (points, length)
  raise "The star must have an odd number of points" if points % 2 == 0
  points.times do
    line length
    turn (720.0/points).degrees
  end
end