Class: Morandi::Colourify

Inherits:
ImageOp
  • Object
show all
Defined in:
lib/morandi/image-ops.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ImageOp

new_from_hash, #priority

Constructor Details

#initialize(op, alpha = 255) ⇒ Colourify

Returns a new instance of Colourify.



268
269
270
271
272
# File 'lib/morandi/image-ops.rb', line 268

def initialize(op, alpha=255)
  super()
  @op = op
  @alpha = alpha
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



267
268
269
# File 'lib/morandi/image-ops.rb', line 267

def op
  @op
end

Instance Method Details

#alphaObject



274
275
276
# File 'lib/morandi/image-ops.rb', line 274

def alpha
  @alpha || 255
end

#bluetone(pixbuf) ⇒ Object



282
283
284
# File 'lib/morandi/image-ops.rb', line 282

def bluetone(pixbuf)
  PixbufUtils.tint(pixbuf, -10, 5, 25, alpha)
end

#call(image, pixbuf) ⇒ Object



297
298
299
300
301
302
303
# File 'lib/morandi/image-ops.rb', line 297

def call(image, pixbuf)
  if @op and respond_to?(@op)
    __send__(@op, pixbuf)
  else
    pixbuf # Default is nothing
  end
end

#greyscale(pixbuf) ⇒ Object Also known as: bw



292
293
294
# File 'lib/morandi/image-ops.rb', line 292

def greyscale(pixbuf)
  PixbufUtils.tint(pixbuf, 0, 0, 0, alpha)
end

#null(pixbuf) ⇒ Object Also known as: full, colour



286
287
288
# File 'lib/morandi/image-ops.rb', line 286

def null(pixbuf)
  pixbuf
end

#sepia(pixbuf) ⇒ Object



278
279
280
# File 'lib/morandi/image-ops.rb', line 278

def sepia(pixbuf)
  PixbufUtils.tint(pixbuf, 25, 5, -25, alpha)
end