class DYI::Shape::Circle

The circle in the vector image @since 0.0.0

Public Class Methods

create_on_center_radius(center, radius, options={}) click to toggle source
# File lib/dyi/shape/base.rb, line 557
def create_on_center_radius(center, radius, options={})
  new(center, radius, options)
end
new(center, radius, options={}) click to toggle source

@param [Coordinate] center a center coordinate of the circle @param [Length] radius a radius length of the circle @option options [Painting] :painting painting status of this shape @option options [String] :description the description of this shape @option options [String] :title the title of this shape

# File lib/dyi/shape/base.rb, line 519
def initialize(center, radius, options={})
  @center = Coordinate.new(center)
  @radius = Length.new(radius).abs
  @attributes = init_attributes(options)
end

Public Instance Methods

bottom() click to toggle source
# File lib/dyi/shape/base.rb, line 537
def bottom
  @center.y + @radius
end
height() click to toggle source
# File lib/dyi/shape/base.rb, line 545
def height
  @radius * 2
end
left() click to toggle source
# File lib/dyi/shape/base.rb, line 525
def left
  @center.x - @radius
end
right() click to toggle source
# File lib/dyi/shape/base.rb, line 529
def right
  @center.x + @radius
end
top() click to toggle source
# File lib/dyi/shape/base.rb, line 533
def top
  @center.y - @radius
end
width() click to toggle source
# File lib/dyi/shape/base.rb, line 541
def width
  @radius * 2
end
write_as(formatter, io=$>) click to toggle source
# File lib/dyi/shape/base.rb, line 549
def write_as(formatter, io=$>)
  formatter.write_circle(self, io, &(block_given? ? Proc.new : nil))
end