Class: ShatteredMachine::Brush

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

Overview

Brush pixels of a given png image. The logic for the brush come from the Rusty Engine.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Brush

Returns a new instance of Brush.

Parameters:

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

    options for brush algorithm



10
11
12
13
14
15
# File 'lib/shattered_machine/brush.rb', line 10

def initialize(options = {})
  @direction = options[:direction] || :horizontal_inverted
  @probability = (options[:probability] || 18).to_s
  @min_pixels = (options[:min_pixels] || 1).to_s
  @max_pixels = (options[:max_pixels] || 10).to_s
end

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of brush.

Parameters:

  • input_image (string)

    path for image

  • output_image (string)

    path for output brushed image

Returns:

  • (boolean)

    status of brush



20
21
22
23
24
25
26
# File 'lib/shattered_machine/brush.rb', line 20

def call(input_image, output_image)
  ruby_to_rust_directions = { horizontal: '1', vertical: '2',
                              horizontal_inverted: '3',
                              vertical_inverted: '4' }
  RustyEngine.brush(input_image, output_image, @probability, @min_pixels,
                    @max_pixels, ruby_to_rust_directions[@direction])
end