X11 Programming - Moving an Object in a GC?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, i'm trying to move a triangel i've drawn with XDrawLine from left to
right. This is the best idea i came up with: i move the coordinates in  
a for-loop and draw on the last ones with white.

int counter=0, x1=0, y1=0, x2=15, y2=15, x3=0, y3=30, start=1;
for (counter; counter < 100; counter++)
{
  if(!start) /* if already drawn */
  {
    /* delete last step -> draw in white */	  
    XSetForeground(display, gc, WhitePixel(display, screen_num));
    XDrawLine(display, win, gc, x1+counter-1, y1, x2+counter-1, y2);
    XDrawLine(display, win, gc, x2+counter-1, y2, x3+counter-1, y3); 
    XDrawLine(display, win, gc, x3+counter-1, y3, x1+counter-1, y1);
   }
   /* draw next step in black */
   XSetForeground(display, gc, BlackPixel(display, screen_num));
   XDrawLine(display, win, gc, x1+counter, y1, x2+counter, y2);
   XDrawLine(display, win, gc, x2+counter, y2, x3+counter, y3);
   XDrawLine(display, win, gc, x3+counter, y3, x1+counter, y1);
   XFlush(display);

   usleep(100000);
   start= 1;
}

Can anyone tell me how to update the GC in order to emulate motion?

Thanks and best regards,
Iqbal
-- 
echo "[q]sa[ln0=aln256%Pln256/snlbx]sb9110849205086363247337574050075\
032905184391195412274100697358608023133864165787933915045683432087129\
472907338347329339706073226139582008068077725378669120069632snlbxq"|dc

_______________________________________________
XFree86 mailing list
XFree86@xxxxxxxxxxx
http://XFree86.Org/mailman/listinfo/xfree86

[Index of Archives]     [X Forum]     [Xorg]     [XFree86 Newbie]     [IETF Announce]     [Security]     [Font Config]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux Kernel]

  Powered by Linux