Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

lines.c

00001 /* Line Drawing Example
00002    Copyright (C) 2003 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@nerim.fr)       
00004 
00005 This file is part of GEL.
00006 
00007 GEL is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2, or (at your option)
00010 any later version.
00011 
00012 GEL is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with GEL; see the file COPYING.  If not, write to
00019 the Free Software Foundation, 59 Temple Place - Suite 330,
00020 Boston, MA 02111-1307, USA.  */
00021 
00034 #include <gdm/display.h>
00035 #include <gdm/display-hw.h>
00036 
00037 /* The display control structure (hardware control and image).  */
00038 gdm_display display;
00039 
00040 int
00041 main ()
00042 {
00043   unsigned short x = 0;
00044   unsigned short y = 0;
00045   unsigned short w = 31;
00046   unsigned short h = 31;
00047   unsigned short ox = 0;
00048   unsigned short oy = 0;
00049   unsigned short ow = 0;
00050   unsigned short oh = 0;
00051   short lx = 0;
00052   short ly = 0;
00053   unsigned short olx = 0;
00054   unsigned short oly = 0;
00055   short dx = 1;
00056   short dy = 0;
00057 
00058   /* Initialize display control.  The display control should be a static
00059      variable (because it's big).  */
00060   gdm_initialize (&display);
00061 
00062   /* Setup to use the exclusive OR drawing mode.  */
00063   gdm_set_gc (&display, GDM_PLOT_XOR);
00064   while (1)
00065     {
00066       if (ow)
00067         {
00068           gdm_fill_rectangle (&display, ox, oy, ow, oh);
00069           gdm_draw_circle (&display, ox, oy, 30);
00070           gdm_draw_line (&display, 64, 32, olx, oly);
00071         }
00072       gdm_fill_rectangle (&display, x, y, w, h);
00073       gdm_draw_circle (&display, x, y, 30);
00074       gdm_draw_line (&display, 64, 32, lx, ly);
00075       ox = x;
00076       oy = y;
00077       ow = w;
00078       oh = h;
00079       olx = lx;
00080       oly = ly;
00081       x++;
00082       if (x >= 128) {
00083         x = 0;
00084         y++;
00085         if (y > 64)
00086           y = 0;
00087       }
00088 
00089       lx += dx;
00090       if (lx >= 128)
00091         {
00092           lx = 127;
00093           dx = 0;
00094           dy = 1;
00095         }
00096       else if (lx < 0)
00097         {
00098           lx = 0;
00099           dx = 0;
00100           dy = -1;
00101         }
00102       ly += dy;
00103       if (ly >= 64)
00104         {
00105           ly = 63;
00106           dy = 0;
00107           dx = -1;
00108         }
00109       else if (ly < 0)
00110         {
00111           ly = 0;
00112           dy = 0;
00113           dx = 1;
00114         }
00115 
00116       /* gdm_touch (&display, 0, 0, 128, 64);*/
00117       gdm_refresh (&display);
00118     }
00119 }