class DrawSvg::Item

Constants

DEFAULT_SCALE

Attributes

items[R]
location[R]
parent[R]

Public Class Methods

new(parent, location, opts={}) click to toggle source
# File lib/drawsvg.rb, line 98
def initialize parent, location, opts={}
  @parent, @location = parent, Point.new(location)
  @scale = Scale.new(opts[:scale] || DEFAULT_SCALE)
  @parent.items << self
  @items = []
  draw
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/drawsvg.rb, line 108
def <=> other
  self.object_id <=> other.object_id
end
absolute_location() click to toggle source
# File lib/drawsvg.rb, line 113
def absolute_location; parent.absolute_location + location; end
canvas() click to toggle source
# File lib/drawsvg.rb, line 120
def canvas
  return parent if parent.is_a? Canvas
  return parent.canvas
end
delete() click to toggle source
# File lib/drawsvg.rb, line 114
def delete
  @parent.delete(self)
end
draw() click to toggle source
# File lib/drawsvg.rb, line 105
def draw
  raise NotImplementedError
end
img() click to toggle source
# File lib/drawsvg.rb, line 111
def img; canvas.img; end
scale() click to toggle source
# File lib/drawsvg.rb, line 112
def scale; parent.scale * @scale; end
to_svg(img) click to toggle source
# File lib/drawsvg.rb, line 117
def to_svg img
  @items.each {|i| i.to_svg img }
end