lib/image_mosaic/image/parent.rb in image_mosaic-0.1.0 vs lib/image_mosaic/image/parent.rb in image_mosaic-0.1.1

- old
+ new

@@ -1,28 +1,26 @@ module ImageMosaic module Image - #Takes an array of images and metrics and then returns a single image of compisited images. + #Takes an array of images and metrics and then returns a single image of composited images. class Parent - def initialize(items, width: 1000, height: 1000, colour: 'white', columns: 5, cell_dimension: 200) + def initialize(items, colour: 'white', columns: 5, dimension: 200) @items = items - @width = width - @height = height @colour = colour @columns = columns - @cell_dimension = cell_dimension + @dimension = dimension end def create - image.run_command(:convert, '-size', "#{@width}x#{@height}", "xc:#{@colour}", image.path) + image.run_command(:convert, '-size', "#{WIDTH}x#{HEIGHT}", "xc:#{@colour}", image.path) y = 0 sliced_grid.each do |row| x = 0 row.each do |cell| @image = add_image(cell, x, y) - x += @cell_dimension + x += @dimension end - y += @cell_dimension + y += @dimension end image end private @@ -30,10 +28,10 @@ def sliced_grid @items.each_slice(@columns).to_a end def add_image(child_image, x, y) - Operations::Compositor.new(@image, child_image).save(x, y, type: 'Over', dimension: @cell_dimension) + Operations::Compositor.new(@image, child_image).save(x, y, type: 'Over', dimension: @dimension) end def temp_file @temp_file ||= Tempfile.new(['image_mosaic', '.png']) end