| Class | Joyau::Rect |
| In: |
Drawable.cpp
|
| Parent: | Object |
Rects are used in order to represent simple rectangle. They’re not here to be drawn, but rather to be used in a basic collision system.
For instance, you can get one from Joyau::Drawable#boundingRect.
Creates a new Rect.
/*
call-seq: Joyau::Rect.new
Joyau::Rect.new(x, y)
Joyau::Rect.new(x, y, w, h)
Creates a new Rect.
*/
VALUE wrap<Rect>(int argc, VALUE *argv, VALUE info)
{
Rect *ptr = new Rect;
VALUE x, y, w, h;
rb_scan_args(argc, argv, "04", &x, &y, &w, &h);
if (!NIL_P(x) && !NIL_P(y))
{
ptr->x = FIX2INT(x);
ptr->y = FIX2INT(y);
if (!NIL_P(w) && !NIL_P(h))
{
ptr->w = FIX2INT(w);
ptr->h = FIX2INT(h);
}
}
VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<Rect>, ptr);
return tdata;
}
Returns a rect’s height.
/*
Returns a rect's height.
*/
VALUE Rect_getH(VALUE self)
{
Rect &ref = getRef<Rect>(self);
return INT2FIX(ref.h);
}
Sets a rect’s height.
/*
call-seq: h=(val)
Sets a rect's height.
*/
VALUE Rect_setH(VALUE self, VALUE val)
{
Rect &ref = getRef<Rect>(self);
int _val = FIX2INT(val);
ref.h = _val;
return val;
}
Returns a rect’s width.
/*
Returns a rect's width.
*/
VALUE Rect_getW(VALUE self)
{
Rect &ref = getRef<Rect>(self);
return INT2FIX(ref.w);
}
Sets a rect’s width.
/*
call-seq: w=(val)
Sets a rect's width.
*/
VALUE Rect_setW(VALUE self, VALUE val)
{
Rect &ref = getRef<Rect>(self);
int _val = FIX2INT(val);
ref.w = _val;
return val;
}
Returns a rect’s abscissa.
/*
Returns a rect's abscissa.
*/
VALUE Rect_getX(VALUE self)
{
Rect &ref = getRef<Rect>(self);
return INT2FIX(ref.x);
}
Sets a rect’s abscissa.
/*
call-seq: x=(val)
Sets a rect's abscissa.
*/
VALUE Rect_setX(VALUE self, VALUE val)
{
Rect &ref = getRef<Rect>(self);
int _val = FIX2INT(val);
ref.x = _val;
return val;
}