Class: ShatteredMachine::Defect

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

Overview

Use the defect algorithm from pnglitch on a given png image.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Defect

Returns a new instance of Defect.

Parameters:

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

    options for defect algorithm



8
9
10
11
# File 'lib/shattered_machine/defect.rb', line 8

def initialize(options = {})
  @random = options[:random] || false
  @iterations = options[:iterations] || 1
end

Instance Method Details

#call(input_image, output_image) ⇒ boolean

Returns status of defect.

Parameters:

  • input_image (string)

    path for input image

  • output_image (string)

    path for output defected image

Returns:

  • (boolean)

    status of defect



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

def call(input_image, output_image)
  PNGlitch.open(input_image) do |png|
    filtered_glitch(png).save output_image
  end
  output_image
end