mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
implemented CvSize2D32f#to_s, CvSize2D32f#to_ary, and added some tests for CvSize and CvSize2D32f
This commit is contained in:
parent
171310a301
commit
04bb08414b
4 changed files with 175 additions and 0 deletions
|
@ -51,6 +51,8 @@ define_ruby_class()
|
|||
rb_define_method(rb_klass, "width=", RUBY_METHOD_FUNC(rb_set_width), 1);
|
||||
rb_define_method(rb_klass, "height", RUBY_METHOD_FUNC(rb_height), 0);
|
||||
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
|
||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -168,6 +170,36 @@ rb_set_height(VALUE self, VALUE y)
|
|||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* to_s -> "<OpenCV::CvSize2D32f:widthxheight>"
|
||||
*
|
||||
* Return width and height by String.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* to_ary -> [width, height]
|
||||
*
|
||||
* Return width and height by Array.
|
||||
*/
|
||||
VALUE
|
||||
rb_to_ary(VALUE self)
|
||||
{
|
||||
return rb_ary_new3(2, rb_width(self), rb_height(self));
|
||||
}
|
||||
|
||||
VALUE
|
||||
new_object(CvSize2D32f size)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue