lib/yamg/splash.rb in yamg-0.3.1 vs lib/yamg/splash.rb in yamg-0.3.3

- old
+ new

@@ -4,10 +4,19 @@ # # class Splash attr_accessor :src, :bg, :size, :assets, :img + # + # Splash + # + # Splash.new(src, size, rounded).image + # Image class + # + # Icon.new(src, size, rounded).image('.path.ext') + # Export image + # def initialize(src, size, background) @src = src @size = size @bg = background @assets = YAMG.load_images(src) @@ -24,11 +33,11 @@ # # Center image # def splash_start - icon_size = size.max / 9 + icon_size = size.min / 5 img.resize icon_size if img.dimensions.max >= icon_size img.combine_options do |o| o.gravity 'center' o.background bg if bg o.extent size.join('x') # "WxH" @@ -56,14 +65,15 @@ self.img = compose(other, over) end end # - # Writes image to disk + # Outputs instance or writes image to disk # - def image(out) + def image(out = nil) splash_start splash_composite + return img unless out FileUtils.mkdir_p File.dirname(out) img.write(out) rescue Errno::ENOENT YAMG.puts_and_exit("Path not found '#{out}'") end