Beispiel #1
0
static void
circle_factory_set_xy2(Object_t *obj, guint state, gint x, gint y)
{
   Circle_t *circle = ObjectToCircle(obj);

   x -= circle->x;
   y -= circle->y;
   circle->r = (gint) sqrt(x * x + y * y);

   main_set_dimension(circle->r, circle->r);
}
Beispiel #2
0
static void
circle_factory_set_xy1(Object_t *obj, guint state, gint x, gint y)
{
   Circle_t *circle = ObjectToCircle(obj);

   circle->x = (_start_x + x) / 2;
   circle->y = (_start_y + y) / 2;
   x -= _start_x;
   y -= _start_y;
   circle->r = (gint) sqrt(x * x + y * y) / 2;

   main_set_dimension(circle->r, circle->r);
}
static void
rectangle_factory_set_xy(Object_t *obj, guint state, gint x, gint y)
{
   Rectangle_t *rectangle = ObjectToRectangle(obj);

   rectangle->width = x - rectangle->x;
   rectangle->height = y - rectangle->y;

   if (state & GDK_SHIFT_MASK){
      gint width = abs(rectangle->width);
      gint height = abs(rectangle->height);
      if (width < height)
         rectangle->height = (rectangle->height < 0) ? -width : width;
      else
         rectangle->width = (rectangle->width < 0) ? -height : height;
   }

   main_set_dimension(rectangle->width, rectangle->height);
}