class Morandi::Crop

Attributes

area[RW]

Public Class Methods

new(area=nil) click to toggle source
Calls superclass method Morandi::ImageOp::new
# File lib/morandi/image-ops.rb, line 23
def initialize(area=nil)
  super()
  @area = area
end

Public Instance Methods

call(image, pixbuf) click to toggle source
# File lib/morandi/image-ops.rb, line 36
def call(image, pixbuf)
  if @area and (not @area.width.zero?) and (not @area.height.zero?)
    # NB: Cheap - fast & shares memory
    GdkPixbuf::Pixbuf.new(pixbuf, @area.x, @area.y,
        @area.width, @area.height)
  else
    pixbuf
  end
end
constrain(val,min,max) click to toggle source
# File lib/morandi/image-ops.rb, line 27
def constrain(val,min,max)
  if val < min
    min
  elsif val > max
    max
  else
    val
  end
end