Class: ShatteredMachine::Exchange
- Inherits:
-
Object
- Object
- ShatteredMachine::Exchange
- Defined in:
- lib/shattered_machine/exchange.rb
Overview
Use the exchange algorithm from pnglitch on a given png image.
Constant Summary collapse
- ALL_FILTERS =
%w[none sub up average paeth].freeze
Instance Method Summary collapse
-
#call(input_image, output_image) ⇒ boolean
Status of exchange.
-
#initialize(options = {}) ⇒ Exchange
constructor
A new instance of Exchange.
Constructor Details
#initialize(options = {}) ⇒ Exchange
Returns a new instance of Exchange.
10 11 12 13 14 15 |
# File 'lib/shattered_machine/exchange.rb', line 10 def initialize( = {}) @filter = define_filter([:filter]) || 'average' @random = [:random] || false @range = [:range] || 0 @seed = [:seed] || 'x' end |
Instance Method Details
#call(input_image, output_image) ⇒ boolean
Returns status of exchange.
20 21 22 23 24 25 |
# File 'lib/shattered_machine/exchange.rb', line 20 def call(input_image, output_image) PNGlitch.open(input_image) do |png| filtered_glitch(png, @filter).save output_image end output_image end |