module DynamicImage::Model::Dimensions
DynamicImage
Model
Dimensions
¶ ↑
Public Instance Methods
Source
# File lib/dynamic_image/model/dimensions.rb, line 18 def crop_gravity if crop_gravity? vector(crop_gravity_x, crop_gravity_y) elsif cropped? crop_start + (crop_size / 2) elsif size? size / 2 end end
Returns the crop gravity.
DynamicImage
will try to keep the pixel represented by crop_gravity
as close to the center as possible when cropping images.
It is relative to 0,0 on the original image.
Unless crop_gravity
has been explicitely set, it defaults to the center of the cropped image.
Source
# File lib/dynamic_image/model/dimensions.rb, line 29 def crop_gravity? crop_gravity_x.present? && crop_gravity_y.present? end
Returns true if crop gravity has been explicitely set.
Source
# File lib/dynamic_image/model/dimensions.rb, line 34 def crop_size vector(crop_width, crop_height) if crop_size? end
Returns the crop size, or nil if no cropping is applied.
Source
# File lib/dynamic_image/model/dimensions.rb, line 39 def crop_size? crop_width? && crop_height? end
Returns true if crop size has been set.
Source
# File lib/dynamic_image/model/dimensions.rb, line 44 def crop_start if crop_start? vector(crop_start_x, crop_start_y) else vector(0, 0) end end
Returns the crop start if set, or Vector2d(0, 0) if not.
Source
# File lib/dynamic_image/model/dimensions.rb, line 53 def crop_start? crop_start_x.present? && crop_start_y.present? end
Returns true if crop start has been set.
Source
# File lib/dynamic_image/model/dimensions.rb, line 58 def cropped? crop_size? && real_size? && crop_size != real_size end
Returns true if the image is cropped.
Source
# File lib/dynamic_image/model/dimensions.rb, line 63 def real_size vector(real_width, real_height) if real_size? end
Returns the real size of the image, without any cropping applied.
Source
# File lib/dynamic_image/model/dimensions.rb, line 68 def real_size? real_width? && real_height? end
Returns true if the size has been set.
Source
# File lib/dynamic_image/model/dimensions.rb, line 74 def size crop_size || real_size end
Returns the cropped size if the image has been cropped. If not, it returns the actual size.
Source
# File lib/dynamic_image/model/dimensions.rb, line 79 def size? size ? true : false end
Returns true if the image has size set.
Private Instance Methods
Source
# File lib/dynamic_image/model/dimensions.rb, line 85 def vector(width, height) Vector2d.new(width, height) end