Class Joyau::Circle
In: Drawable.cpp
Parent: Joyau::FillableShape

Class used when drawing Circle.

Methods

center   center=   centerX   centerY   center_x   center_y   getCenterX   getCenterY   getRadius   new   radius   radius=   setCenter   setRadius  

Public Class methods

Creates a new circle.

[Source]

/*
  call-seq: new(radius, x, y)
            new(radius, point)
  
  Creates a new circle.
*/
VALUE wrap<Circle>(int argc, VALUE *argv, VALUE info)
{
   Circle *ptr = new Circle;

   VALUE radius, arg2, arg3;
   rb_scan_args(argc, argv, "03", &radius, &arg2, &arg3);

   if (!NIL_P(radius))
   {
      ptr->setRadius(FIX2INT(radius));
      
      if (NIL_P(arg3) && !NIL_P(arg2))
         ptr->setPos(getRef<Point>(arg2));
      else if (!NIL_P(arg2))
         ptr->setPos(FIX2INT(arg2), FIX2INT(arg3));
      else
         rb_raise(rb_eArgError, "Center's position not given.");
   }

   VALUE tdata = Data_Wrap_Struct(info, 0, wrapped_free<Circle>, ptr);
   return tdata;
}

Public Instance methods

Returns the center as Point

[Source]

/*
  Returns the center as Point
*/
VALUE Circle_center(VALUE self)
{
   Circle &ref = getRef<Circle>(self);
   Point p(ref.getCenterX(), ref.getCenterY());
   return createObject(getClass("Point"), p);
}

Sets the circle’s center.

[Source]

/*
  call-seq: center=(point)

  Sets the circle's center.
*/
VALUE Circle_setCenterPoint(VALUE self, VALUE point)
{
   Circle &ref = getRef<Circle>(self);
   Point &p = getRef<Point>(point);
   
   ref.setCenter(p.x, p.y);
   return point;
}
centerX()

Alias for getCenterX

centerY()

Alias for getCenterY

center_x()

Alias for getCenterX

center_y()

Alias for getCenterY

Returns the center’s abscissa.

[Source]

/*
  Returns the center's abscissa.
*/
VALUE Circle_getCenterX(VALUE self)
{
   Circle &ref = getRef<Circle>(self);
   return INT2FIX(ref.getCenterX());
}

Returns the center’s ordinate.

[Source]

/*
  Returns the center's ordinate.
*/
VALUE Circle_getCenterY(VALUE self)
{
   Circle &ref = getRef<Circle>(self);
   return INT2FIX(ref.getCenterX());
}

Returns the radius.

[Source]

/*
  Returns the radius.
*/
VALUE Circle_getRadius(VALUE self)
{
   Circle &ref = getRef<Circle>(self);
   return INT2FIX(ref.getRadius());
}
radius()

Alias for getRadius

radius=(p1)

Alias for setRadius

Sets the circle’s center.

[Source]

/*
  call-seq: setCenter(x, y)

  Sets the circle's center.
*/
VALUE Circle_setCenter(VALUE self, VALUE x, VALUE y)
{
   Circle &ref = getRef<Circle>(self);
   int _x = FIX2INT(x);
   int _y = FIX2INT(y);

   ref.setCenter(_x, _y);
   return Qnil;
}

Sets the circle’s radius.

[Source]

/*
  call-seq: setRadius(r)

  Sets the circle's radius.
*/
VALUE Circle_setRadius(VALUE self, VALUE r)
{
   Circle &ref = getRef<Circle>(self);
   int _r = FIX2INT(r);

   ref.setRadius(_r);
   return r;
}

[Validate]