Method: Pixelart::Vector#save

Defined in:
lib/pixelart/vector.rb

#save(path, format: nil) ⇒ Object Also known as: write



147
148
149
150
151
152
153
154
155
156
157
158
159
# File 'lib/pixelart/vector.rb', line 147

def save( path, format: nil )
  if format && format.downcase == 'png'  ## support png with image magick
    img = to_image
    img.save( path )
  else
   # make sure outdir exits
   outdir = File.dirname( path )
   FileUtils.mkdir_p( outdir )  unless Dir.exist?( outdir )
   File.open( path, 'w:utf-8' ) do |f|
      f.write( to_svg )
    end
  end
end