SparkCanvas.class_eval do
def to_uri
require 'base64'
# doesn't attempt to respect some limits noted in RFC 2397 since the data:
# url is supposed to be 'short' (1k), but the meaning of that word has changed
# a bit since 1998.
# Modern browsers allow 4k-32k or more According to http://dataurl.net/#about %{data:image/png;base64,#{Base64.encode64(to_png).gsub("\n",'')}}
end
end