class DrawSvg::Circle
TODO: consider making only an Ellipse class with a Circle
wrapper
Attributes
radius[W]
Public Class Methods
new(parent, location, radius, opts={})
click to toggle source
Calls superclass method
DrawSvg::Item::new
# File lib/drawsvg.rb, line 162 def initialize parent, location, radius, opts={} #location is center of circle by default super(parent, location) @radius, @opts = radius, opts @draw_from = @opts.delete(:draw_from) || :center @snap = @opts.delete(:snap) end
Public Instance Methods
center()
click to toggle source
# File lib/drawsvg.rb, line 172 def center if @draw_from == :bottom location + Point[0, radius] else location end end
center_absolute()
click to toggle source
# File lib/drawsvg.rb, line 182 def center_absolute parent.absolute_location + center end
center_svg()
click to toggle source
# File lib/drawsvg.rb, line 185 def center_svg Point.new(center_absolute.x, (canvas.height - center_absolute.y)).round end
draw()
click to toggle source
# File lib/drawsvg.rb, line 168 def draw; end
radius()
click to toggle source
# File lib/drawsvg.rb, line 179 def radius (@radius*scale.x).round end
to_svg(img)
click to toggle source
# File lib/drawsvg.rb, line 169 def to_svg img img.circle(center_svg.x, center_svg.y, radius, Rasem::SVGImage::DefaultStyles[:line].merge(fill: 'white').merge(@opts)) end