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.

Methods

h   h=   new   w   w=   x   x=   y   y=  

Public Class methods

Creates a new Rect.

[Source]

/*
  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;
}

Public Instance methods

Returns a rect’s height.

[Source]

/*
  Returns a rect's height.
*/
VALUE Rect_getH(VALUE self)
{
   Rect &ref = getRef<Rect>(self);
   return INT2FIX(ref.h);
}

Sets a rect’s height.

[Source]

/*
  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.

[Source]

/*
  Returns a rect's width.
*/
VALUE Rect_getW(VALUE self)
{
   Rect &ref = getRef<Rect>(self);
   return INT2FIX(ref.w);
}

Sets a rect’s width.

[Source]

/*
  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.

[Source]

/*
  Returns a rect's abscissa.
*/
VALUE Rect_getX(VALUE self)
{
   Rect &ref = getRef<Rect>(self);
   return INT2FIX(ref.x);
}

Sets a rect’s abscissa.

[Source]

/*
  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;
}

Returns a rect’s ordinate.

[Source]

/*
  Returns a rect's ordinate.
*/
VALUE Rect_getY(VALUE self)
{
   Rect &ref = getRef<Rect>(self);
   return INT2FIX(ref.y);
}

Sets a rect’s ordinate.

[Source]

/*
  call-seq: y=(val)

  Sets a rect's ordinate.
*/
VALUE Rect_setY(VALUE self, VALUE val)
{
   Rect &ref = getRef<Rect>(self);
   int _val = FIX2INT(val);

   ref.y = _val;
   return val;
}

[Validate]