Class: Morandi::Crop
Instance Attribute Summary collapse
-
#area ⇒ Object
Returns the value of attribute area.
Instance Method Summary collapse
- #call(image, pixbuf) ⇒ Object
- #constrain(val, min, max) ⇒ Object
-
#initialize(area = nil) ⇒ Crop
constructor
A new instance of Crop.
Methods inherited from ImageOp
Constructor Details
#initialize(area = nil) ⇒ Crop
Returns a new instance of Crop.
23 24 25 26 |
# File 'lib/morandi/image-ops.rb', line 23 def initialize(area=nil) super() @area = area end |
Instance Attribute Details
#area ⇒ Object
Returns the value of attribute area.
22 23 24 |
# File 'lib/morandi/image-ops.rb', line 22 def area @area end |
Instance Method Details
#call(image, pixbuf) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# 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 Gdk::Pixbuf.new(pixbuf, @area.x, @area.y, @area.width, @area.height) else pixbuf end end |
#constrain(val, min, max) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# 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 |