home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xmu / DrawLogo.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-01  |  3.8 KB  |  131 lines

  1. /* static char Xrcsid[] = "$XConsortium: DrawLogo.c,v 1.3 90/12/01 12:58:02 rws Exp $"; */
  2.  
  3. #include <X11/Xlib.h>  
  4.  
  5. /*
  6. Copyright 1988 by the Massachusetts Institute of Technology
  7.  
  8. Permission to use, copy, modify, and distribute this
  9. software and its documentation for any purpose and without
  10. fee is hereby granted, provided that the above copyright
  11. notice appear in all copies and that both that copyright
  12. notice and this permission notice appear in supporting
  13. documentation, and that the name of M.I.T. not be used in
  14. advertising or publicity pertaining to distribution of the
  15. software without specific, written prior permission.
  16. M.I.T. makes no representations about the suitability of
  17. this software for any purpose.  It is provided "as is"
  18. without express or implied warranty.
  19. */
  20.  
  21. /*
  22.  *  Draw the "official" X Window System Logo, designed by Danny Chong
  23.  *
  24.  *  Written by Ollie Jones, Apollo Computer
  25.  *
  26.  *  Does some fancy stuff to make the logo look acceptable even
  27.  *  if it is tiny.  Also makes the various linear elements of
  28.  *  the logo line up as well as possible considering rasterization.
  29.  */
  30.  
  31. XmuDrawLogo(dpy, drawable, gcFore, gcBack, x, y, width, height)
  32.     Display *dpy;
  33.     Drawable drawable;
  34.     GC gcFore, gcBack;
  35.     int x, y;
  36.     unsigned int width, height;
  37. {
  38.  
  39.     unsigned int size;
  40.     int d11, d21, d31;
  41.     XPoint poly[4];
  42.  
  43.     XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
  44.  
  45.     /* for now, do a centered even-sized square, at least for now */
  46.     size = width;
  47.     if (height < width)
  48.      size = height;
  49.     size &= ~1;
  50.     x += (width - size) >> 1;
  51.     y += (height - size) >> 1;
  52.  
  53. /*    
  54.  *           ----- 
  55.  *          /    /
  56.  *         /    /
  57.  *        /    /
  58.  *       /    /
  59.  *      /____/
  60.  */
  61.  
  62.     d11 = (size / 11);
  63.     if (d11 < 1) d11 = 1;
  64.     d21 = (d11+3) / 4;
  65.     d31 = d11 + d11 + d21;
  66.     poly[0].x = x + size;              poly[0].y = y;
  67.     poly[1].x = x + size-d31;          poly[1].y = y;
  68.     poly[2].x = x + 0;                 poly[2].y = y + size;
  69.     poly[3].x = x + d31;               poly[3].y = y + size;
  70.     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
  71.  
  72. /*    
  73.  *           ------ 
  74.  *          /     /
  75.  *         /  __ /
  76.  *        /  /  /
  77.  *       /  /  /
  78.  *      /__/__/
  79.  */
  80.  
  81.     poly[0].x = x + d31/2;                       poly[0].y = y + size;
  82.     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
  83.     poly[2].x = x + (size/2)+(d31-(d31/2));      poly[2].y = y + size/2;
  84.     poly[3].x = x + d31;                         poly[3].y = y + size;
  85.     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
  86.  
  87. /*    
  88.  *           ------ 
  89.  *          /  /  /
  90.  *         /--/  /
  91.  *        /     /
  92.  *       /     /
  93.  *      /_____/
  94.  */
  95.  
  96.     poly[0].x = x + size - d31/2;                poly[0].y = y;
  97.     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
  98.     poly[2].x = x + (size/2)-(d31-(d31/2));      poly[2].y = y + size/2;
  99.     poly[3].x = x + size - d31;                  poly[3].y = y;
  100.     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
  101.  
  102. /*
  103.  * -----
  104.  * \    \
  105.  *  \    \
  106.  *   \    \
  107.  *    \    \
  108.  *     \____\
  109.  */
  110.  
  111.     poly[0].x = x;                     poly[0].y = y;
  112.     poly[1].x = x + size/4;            poly[1].y = y;
  113.     poly[2].x = x + size;              poly[2].y = y + size;
  114.     poly[3].x = x + size - size/4;     poly[3].y = y + size;
  115.     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
  116.  
  117. /*    
  118.  *          /
  119.  *         /
  120.  *        /
  121.  *       /
  122.  *      /
  123.  */
  124.  
  125.     poly[0].x = x + size- d11;        poly[0].y = y;
  126.     poly[1].x = x + size-( d11+d21);  poly[1].y = y;
  127.     poly[2].x = x + d11;              poly[2].y = y + size;
  128.     poly[3].x = x + d11 + d21;        poly[3].y = y + size;
  129.     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
  130. }
  131.