Class | Joyau::Circle |
In: |
Drawable.cpp
|
Parent: | Joyau::FillableShape |
Class used when drawing Circle.
Creates a new circle.
/* 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; }
Sets the circle’s center.
/* 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; }
Returns the center’s abscissa.
/* Returns the center's abscissa. */ VALUE Circle_getCenterX(VALUE self) { Circle &ref = getRef<Circle>(self); return INT2FIX(ref.getCenterX()); }
Returns the center’s ordinate.
/* Returns the center's ordinate. */ VALUE Circle_getCenterY(VALUE self) { Circle &ref = getRef<Circle>(self); return INT2FIX(ref.getCenterX()); }
Returns the radius.
/* Returns the radius. */ VALUE Circle_getRadius(VALUE self) { Circle &ref = getRef<Circle>(self); return INT2FIX(ref.getRadius()); }
Sets the circle’s center.
/* 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; }