lib/Base/SVGContainer.rb
def use(svg_object,x=0,y=0)
			#If the svg_object has been added to the defs section of the
			#document, it will have an id. If there's an id, we'll just
			#reference the object from the defs section
			#
			#If there's no id, make a clone of the object, and copy it into
			#the container directly (inefficient for making lots of copies)
			#
			#The user can also assign an id themselves if they want. To avoid
			#conflicts, the id should NOT have the form id_123
			begin
				id = svg_object.id #this may trigger a NoMethodError if there's no id
				use = SVG::Use.new(svg_object,x,y)
				
				yield use if block_given?
				 
				@svg_objects << use
				 
				return use
			rescue NoMethodError, e
				#Copy object into container
				#We need to make a copy of the group here to prevent the original
				#being mutated
				copy = svg_object.deep_copy
				copy.translate(x, y) unless (x == 0 && y == 0)
				@svg_objects << copy
				
				yield copy if block_given?
				
				return copy
			end
		end
#A container can "use" a group or other SVGObject
A container can "use" a group or other SVGObject
A container can " use " a group or other SVGObject
def use(svg_object,x=0,y=0)
			If there's no id, make a clone of the object, and copy it into
			the container directly (inefficient for making lots of copies)
			The user can also assign an id themselves if they want. To avoid
			conflicts, the id should NOT have the form id_123
			begin
				id = svg_object.id this may trigger a NoMethodError if there's no id
				use = SVG::Use.new(svg_object,x,y)
				yield use if block_given?
				@svg_objects << use
				return use
			rescue NoMethodError, e
				Copy object into container
				We need to make a copy of the group here to prevent the original
				being mutated
				copy = svg_object.deep_copy
				copy.translate(x, y) unless (x == 0 && y == 0)
				@svg_objects << copy
				yield copy if block_given?
				return copy
			end
		end
def use ( svg_object , x = 0 , y = 0 ) begin id = svg_object . id use = SVG :: Use . new ( svg_object , x , y ) yield use if block_given? @svg_objects << use return use rescue NoMethodError , e copy = svg_object . deep_copy copy . translate ( x , y ) unless ( x == 0 && y == 0 ) @svg_objects << copy yield copy if block_given? return copy end end
A container can "use" a group or other SVGObject
A container can " use " a group or other SVGObject
#If the svg_object has been added to the defs section of the #document, it will have an id. If there's an id, we'll just #reference the object from the defs section # #If there's no id, make a clone of the object, and copy it into #the container directly (inefficient for making lots of copies) # #The user can also assign an id themselves if they want. To avoid #conflicts, the id should NOT have the form id_123 #this may trigger a NoMethodError if there's no id #Copy object into container #We need to make a copy of the group here to prevent the original #being mutated
svg_object
x
y