Class: ShatteredMachine::Slim

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

Overview

Repeat pixels of a given png image. The logic for the pixel sorter come from the Rusty Engine.

Constant Summary collapse

ALL_COLORS =
%i[white black grey red green blue cyan yellow magenta].freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Slim

Returns a new instance of Slim.

Parameters:

  • options (Hash) (defaults to: {})

    options for slim algorithm



12
13
14
15
16
17
18
# File 'lib/shattered_machine/slim.rb', line 12

def initialize(options = {})
  @colors = options[:colors] || ALL_COLORS
  @direction = options[:direction] || :vertical_inverted
  @probability = (options[:probability] || 95).to_s
  @probability_area = options[:probability_area] || 'global'
  @colors_with_proba = colors_with_proba(options[:colors_with_proba])
end

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of slim.

Parameters:

  • input_image (string)

    path for image

  • output_image (string)

    path for output slimed image

Returns:

  • (boolean)

    status of slim



23
24
25
26
27
# File 'lib/shattered_machine/slim.rb', line 23

def call(input_image, output_image)
  RustyEngine.slim(input_image, output_image, @probability, @probability_area,
                   rust_formatted_direction, rust_formatted_colors,
                   rust_formatted_color_with_proba)
end