class Terraformer::Circle

Attributes

center[R]
polygon[RW]
radius[R]
resolution[R]

Public Class Methods

new(c, r, res = DEFAULT_BUFFER_RESOLUTION) click to toggle source
# File lib/terraformer/circle.rb, line 9
def initialize c, r, res = DEFAULT_BUFFER_RESOLUTION
  self.center = c
  self.radius = r
  self.resolution = res
  recalculate
end

Public Instance Methods

center=(c) click to toggle source
# File lib/terraformer/circle.rb, line 22
def center= c
  c = Coordinate.from_array c if Array === c and Numeric === c[0]
  c = c.coordinates if Point === c
  raise ArgumentError unless Coordinate === c
  @center = c
  @dirty = true
  self
end
dirty?() click to toggle source
# File lib/terraformer/circle.rb, line 45
def dirty?
  @dirty
end
radius=(r) click to toggle source
# File lib/terraformer/circle.rb, line 31
def radius= r
  raise ArgumentError unless Numeric === r
  @radius = r
  @dirty = true
  self
end
recalculate() click to toggle source
# File lib/terraformer/circle.rb, line 16
def recalculate
  @polygon = @center.buffer @radius, @resolution
  @dirty = false
  self
end
resolution=(res) click to toggle source
# File lib/terraformer/circle.rb, line 38
def resolution= res
  raise ArgumentError unless Fixnum === res
  @resolution = res
  @dirty = true
  self
end