Class: ShatteredMachine::ProgressivePixelSorter

Inherits:
Object
  • Object
show all
Defined in:
lib/shattered_machine/progressive_pixel_sorter.rb

Overview

Call the pixel sorter multiple time in steps for given png image(s)

Instance Method Summary collapse

Constructor Details

#initialize(io, options) ⇒ ProgressivePixelSorter

Returns a new instance of ProgressivePixelSorter.

Parameters:

  • io (ShatteredMachine::Io)

    Io containing paths for images to glitch

  • options (Hash)

    options for the pixel sorting algorithm



9
10
11
12
13
14
# File 'lib/shattered_machine/progressive_pixel_sorter.rb', line 9

def initialize(io, options)
  @io = io
  @options = options
  @images_count = @io.png_images.count
  @steps = define_steps
end

Instance Method Details

#callObject



16
17
18
19
20
# File 'lib/shattered_machine/progressive_pixel_sorter.rb', line 16

def call
  @io.png_images.sort_by { |path| [path.input[/\d+/].to_i, path.input] }.each_with_index do |item, index|
    PixelSorter.new(sorter_options(index)).call(item.input, item.output)
  end
end