Class: OpenCV::CvSize2D32f

Inherits:
Object
  • Object
show all
Defined in:
ext/opencv/cvsize2d32f.cpp,
ext/opencv/cvsize2d32f.cpp

Overview

This class means one size on X axis Y axis. X and Y takes the value of the Float.

C structure is here, very simple.

typdef struct CvSize2D32f {
  float width;
  float height;
} CvSize2D32f;

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#newObject #new(obj) ⇒ Object #new(width, height) ⇒ Object

Create new size of 2D, (width, height).

new() is same as new(0.0, 0.0)

new(obj) is same as new(obj.x.to_f, obj.y.to_f)



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'ext/opencv/cvsize2d32f.cpp', line 78

VALUE
rb_initialize(int argc, VALUE *argv, VALUE self)
{
  CvSize2D32f *self_ptr = CVSIZE2D32F(self);
  switch(argc){
  case 0:
    break;
  case 1: {
    CvSize2D32f size = VALUE_TO_CVSIZE2D32F(argv[0]);
    self_ptr->width = size.width;
    self_ptr->height = size.height;
    break;
  }
  case 2:
    self_ptr->width = NUM2DBL(argv[0]);
    self_ptr->height = NUM2DBL(argv[1]);
    break;
  default:
    rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
  }
  return self;      
}

Class Method Details

.compatible?(obj) ⇒ Boolean

Return compatibility to CvSize2D32f. Return true if object have method #width and #height.

For example.

class MySize
  def width
    10.1
  end
  def height
    20.2
  end
end
mp = MySize.new
CvSize2D32f.compatible?(mp)  #=> true
CvSize2D32f.new(mp)          #=> same as CvSize2D32f.new(10.1, 20.2)

Returns:

  • (Boolean)


53
54
55
56
57
# File 'ext/opencv/cvsize2d32f.cpp', line 53

VALUE
rb_compatible_q(VALUE klass, VALUE object)
{
  return (rb_respond_to(object, rb_intern("width")) && rb_respond_to(object, rb_intern("height"))) ? Qtrue : Qfalse;
}

Instance Method Details

#heightObject

Return size of yaxis.



126
127
128
129
130
# File 'ext/opencv/cvsize2d32f.cpp', line 126

VALUE
rb_height(VALUE self)
{
  return rb_float_new(CVSIZE2D32F(self)->height);
}

#height=(val) ⇒ Object

Set y-axis size, return self.



138
139
140
141
142
143
# File 'ext/opencv/cvsize2d32f.cpp', line 138

VALUE
rb_set_height(VALUE self, VALUE y)
{
  CVSIZE2D32F(self)->height = NUM2DBL(y);
  return self;
}

#to_aryArray Also known as: to_a

Return width and height by Array.

Returns:

  • (Array)


169
170
171
172
173
# File 'ext/opencv/cvsize2d32f.cpp', line 169

VALUE
rb_to_ary(VALUE self)
{
  return rb_ary_new3(2, rb_width(self), rb_height(self));
}

#to_s"<OpenCV::CvSize2D32f:widthxheight>"

Return width and height by String.

Returns:

  • ("<OpenCV::CvSize2D32f:widthxheight>")


151
152
153
154
155
156
157
158
159
160
161
# File 'ext/opencv/cvsize2d32f.cpp', line 151

VALUE
rb_to_s(VALUE self)
{
  const int i = 4;
  VALUE str[i];
  str[0] = rb_str_new2("<%s:%gx%g>");
  str[1] = rb_str_new2(rb_class2name(CLASS_OF(self)));
  str[2] = rb_width(self);
  str[3] = rb_height(self);
  return rb_f_sprintf(i, str);
}

#widthObject

Return size of x-axis.



104
105
106
107
108
# File 'ext/opencv/cvsize2d32f.cpp', line 104

VALUE
rb_width(VALUE self)
{
  return rb_float_new(CVSIZE2D32F(self)->width);
}

#width=(val) ⇒ Object

Set x-axis size, return self.



116
117
118
119
120
121
# File 'ext/opencv/cvsize2d32f.cpp', line 116

VALUE
rb_set_width(VALUE self, VALUE x)
{
  CVSIZE2D32F(self)->width = NUM2DBL(x);
  return self;
}