Class: CVFFI::Size

Inherits:
Point
  • Object
show all
Includes:
CvSizeCastMethods
Defined in:
lib/opencv-ffi-wrappers/core/size.rb

Instance Attribute Summary

Attributes inherited from Point

#w, #x, #y

Instance Method Summary collapse

Methods included from CvSizeCastMethods

#to_CvSize, #to_CvSize2D32f, #to_CvSize2D64f

Methods included from CvPointMethods

#*, #+, #-, #/, #==, #===, #got_what_i_need, #l2_squared_distance, #l2distance, #neighbor?, #neighbor_rsquared?, #rotate, #to_Vector, #to_a

Methods included from CvPointCastMethods

#to_CvPoint, #to_CvPoint2D32f, #to_CvPoint2D64f, #to_Point, #to_a

Constructor Details

#initialize(*args) ⇒ Size

Returns a new instance of Size.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/opencv-ffi-wrappers/core/size.rb', line 54

def initialize( *args )
  if args.length == 2
    @x= args[0]
    @y= args[1]
  else
    args = args.shift
    case args
    when Hash
      @x= args[:width] || args[:x]
      @y= args[:height] || args[:y]
    when Array
      @x = args[0]
      @y = args[1]
    else
      @x = args.width || args.x
      @y = args.height || args.y
    end
  end
end

Instance Method Details

#areaObject



74
75
76
# File 'lib/opencv-ffi-wrappers/core/size.rb', line 74

def area
  height*width
end

#floorObject



78
79
80
81
# File 'lib/opencv-ffi-wrappers/core/size.rb', line 78

def floor
  @x = x.to_i
  @y = y.to_i
end