def svg(file, svg_args, box, paint, trans)
      Squib.logger.debug {"Rendering: #{file}, id: #{id} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}, mask: #{mask}"}
      Squib.logger.warn 'Both an SVG file and SVG data were specified' unless file.to_s.empty? || svg_args.data.to_s.empty?
      return if (file.nil? or file.eql? '') and svg_args.data.nil? # nothing specified TODO Move this out to arg validator
      svg_args.data = File.read(file) if svg_args.data.to_s.empty?
      begin
        svg = Rsvg::Handle.new_from_data(svg_args.data)
      rescue Rsvg::Error::Failed
        Squib.logger.error "Invalid SVG data. Is '#{file}' a valid svg file?"
        return
      end
      box.width    = svg.width  if box.width == :native
      box.height   = svg.height if box.height == :native
      box.width  = svg.width.to_f * box.height.to_f / svg.height.to_f if box.width == :scale
      box.height = svg.height.to_f * box.width.to_f / svg.width.to_f  if box.height == :scale
      scale_width  = box.width.to_f / svg.width.to_f
      scale_height = box.height.to_f / svg.height.to_f
      use_cairo do |cc|
        cc.translate(box.x, box.y)
        cc.flip(trans.flip_vertical, trans.flip_horizontal, box.width / 2, box.height / 2)
        cc.rotate(trans.angle)
        cc.scale(scale_width, scale_height)

        trans.crop_width  = box.width  if trans.crop_width  == :native
        trans.crop_height = box.height if trans.crop_height == :native
        cc.rounded_rectangle(0, 0, trans.crop_width / scale_width, trans.crop_height / scale_height, trans.crop_corner_x_radius, trans.crop_corner_y_radius)
        cc.clip
        cc.translate(-trans.crop_x, -trans.crop_y)

        cc.operator = paint.blend unless paint.blend == :none
        if paint.mask.to_s.empty?
          cc.render_rsvg_handle(svg, id: svg_args.id)
        else
          tmp = Cairo::ImageSurface.new(box.width / scale_width, box.height / scale_height)
          tmp_cc = Cairo::Context.new(tmp)
          tmp_cc.render_rsvg_handle(svg, id: svg_args.id)
          cc.set_source_squibcolor(paint.mask)
          cc.mask(tmp, 0, 0)
        end
      end
    end
def svg(file, svg_args, box, paint, trans)
      Squib.logger.debug {"Rendering: #{file}, id: #{id} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}, mask: #{mask}"}
      Squib.logger.warn 'Both an SVG file and SVG data were specified' unless file.to_s.empty? || svg_args.data.to_s.empty?
      return if (file.nil? or file.eql? '') and svg_args.data.nil? # nothing specified TODO Move this out to arg validator
      svg_args.data = File.read(file) if svg_args.data.to_s.empty?
      begin
        svg = Rsvg::Handle.new_from_data(svg_args.data)
      rescue Rsvg::Error::Failed
        Squib.logger.error "Invalid SVG data. Is '#{file}' a valid svg file?"
        return
      end
      box.width    = svg.width  if box.width == :native
      box.height   = svg.height if box.height == :native
      box.width  = svg.width.to_f * box.height.to_f / svg.height.to_f if box.width == :scale
      box.height = svg.height.to_f * box.width.to_f / svg.width.to_f  if box.height == :scale
      scale_width  = box.width.to_f / svg.width.to_f
      scale_height = box.height.to_f / svg.height.to_f
      use_cairo do |cc|
        cc.translate(box.x, box.y)
        cc.flip(trans.flip_vertical, trans.flip_horizontal, box.width / 2, box.height / 2)
        cc.rotate(trans.angle)
        cc.scale(scale_width, scale_height)

        trans.crop_width  = box.width  if trans.crop_width  == :native
        trans.crop_height = box.height if trans.crop_height == :native
        cc.rounded_rectangle(0, 0, trans.crop_width / scale_width, trans.crop_height / scale_height, trans.crop_corner_x_radius, trans.crop_corner_y_radius)
        cc.clip
        cc.translate(-trans.crop_x, -trans.crop_y)

        cc.operator = paint.blend unless paint.blend == :none
        if paint.mask.to_s.empty?
          cc.render_rsvg_handle(svg, id: svg_args.id)
        else
          tmp = Cairo::ImageSurface.new(box.width / scale_width, box.height / scale_height)
          tmp_cc = Cairo::Context.new(tmp)
          tmp_cc.render_rsvg_handle(svg, id: svg_args.id)
          cc.set_source_squibcolor(paint.mask)
          cc.mask(tmp, 0, 0)
        end
      end
    end
:nodoc:
 @api private