
Untitled
By: a guest on
May 29th, 2012 | syntax:
None | size: 0.75 KB | hits: 18 | expires: Never
# encoding: utf-8
require 'rubygems'
require 'builder'
svg_doctype = [
:DOCTYPE,
:svg,
:PUBLIC,
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
]
svg_options = {
:xmlns => "http://www.w3.org/2000/svg",
:"xmlns:xlink" => "http://www.w3.org/1999/xlink",
:"xmlns:ev" => "http://www.w3.org/2001/xml-events",
:version => "1.1",
:baseProfile => "full",
:width => "1000px",
:height => "1000px"
}
output = String.new
svg = Builder::XmlMarkup.new indent: 2, target: output
svg.instruct!
svg.declare! *svg_doctype
svg.svg(svg_options) do
svg.circle cx: 500, cy: 500, r: 200, style: "fill:red; stroke:black; stroke-width:10"
end
File.open('output.svg', 'w') { |f| f.write output }