DrawLogo.c

Go to the documentation of this file.
00001 /* $Xorg: DrawLogo.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
00002 
00003 /*
00004 
00005 Copyright 1988, 1998  The Open Group
00006 
00007 Permission to use, copy, modify, distribute, and sell this software and its
00008 documentation for any purpose is hereby granted without fee, provided that
00009 the above copyright notice appear in all copies and that both that
00010 copyright notice and this permission notice appear in supporting
00011 documentation.
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 
00023 Except as contained in this notice, the name of The Open Group shall not be
00024 used in advertising or otherwise to promote the sale, use or other dealings
00025 in this Software without prior written authorization from The Open Group.
00026 
00027 */
00028 /* $XFree86: xc/lib/Xmu/DrawLogo.c,v 1.7 2001/01/17 19:42:54 dawes Exp $ */
00029 
00030 #include <X11/Xlib.h>  
00031 #include <X11/Xmu/Drawing.h>
00032 
00033 /*
00034  *  Draw the "official" X Window System Logo, designed by Danny Chong
00035  *
00036  *  Written by Ollie Jones, Apollo Computer
00037  *
00038  *  Does some fancy stuff to make the logo look acceptable even
00039  *  if it is tiny.  Also makes the various linear elements of
00040  *  the logo line up as well as possible considering rasterization.
00041  */
00042 void
00043 XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack,
00044             int x, int y, unsigned int width, unsigned int height)
00045 {
00046     unsigned int size;
00047     int thin, gap, d31;
00048     XPoint poly[4];
00049 
00050     XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
00051 
00052     /* for now, do a centered even-sized square, at least for now */
00053     size = width;
00054     if (height < width)
00055          size = height;
00056     size &= ~1;
00057     x += (width - size) >> 1;
00058     y += (height - size) >> 1;
00059 
00060 /*    
00061  * Draw what will be the thin strokes.
00062  *
00063  *           ----- 
00064  *          /    /
00065  *         /    /
00066  *        /    /
00067  *       /    /
00068  *      /____/
00069  *           d
00070  *
00071  * Point d is 9/44 (~1/5) of the way across.
00072  */
00073 
00074     thin = (size / 11);
00075     if (thin < 1) thin = 1;
00076     gap = (thin+3) / 4;
00077     d31 = thin + thin + gap;
00078     poly[0].x = x + size;              poly[0].y = y;
00079     poly[1].x = x + size-d31;          poly[1].y = y;
00080     poly[2].x = x + 0;                 poly[2].y = y + size;
00081     poly[3].x = x + d31;               poly[3].y = y + size;
00082     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
00083 
00084 /*    
00085  * Erase area not needed for lower thin stroke.
00086  *
00087  *           ------ 
00088  *          /     /
00089  *         /  __ /
00090  *        /  /  /
00091  *       /  /  /
00092  *      /__/__/
00093  */
00094 
00095     poly[0].x = x + d31/2;                       poly[0].y = y + size;
00096     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
00097     poly[2].x = x + (size/2)+(d31-(d31/2));      poly[2].y = y + size/2;
00098     poly[3].x = x + d31;                         poly[3].y = y + size;
00099     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
00100 
00101 /*    
00102  * Erase area not needed for upper thin stroke.
00103  *
00104  *           ------ 
00105  *          /  /  /
00106  *         /--/  /
00107  *        /     /
00108  *       /     /
00109  *      /_____/
00110  */
00111 
00112     poly[0].x = x + size - d31/2;                poly[0].y = y;
00113     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
00114     poly[2].x = x + (size/2)-(d31-(d31/2));      poly[2].y = y + size/2;
00115     poly[3].x = x + size - d31;                  poly[3].y = y;
00116     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
00117 
00118 /*
00119  * Draw thick stroke.
00120  * Point b is 1/4 of the way across.
00121  *
00122  *      b
00123  * -----
00124  * \    \
00125  *  \    \
00126  *   \    \
00127  *    \    \
00128  *     \____\
00129  */
00130 
00131     poly[0].x = x;                     poly[0].y = y;
00132     poly[1].x = x + size/4;            poly[1].y = y;
00133     poly[2].x = x + size;              poly[2].y = y + size;
00134     poly[3].x = x + size - size/4;     poly[3].y = y + size;
00135     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
00136 
00137 /*    
00138  * Erase to create gap.
00139  *
00140  *          /
00141  *         /
00142  *        /
00143  *       /
00144  *      /
00145  */
00146 
00147     poly[0].x = x + size- thin;        poly[0].y = y;
00148     poly[1].x = x + size-( thin+gap);  poly[1].y = y;
00149     poly[2].x = x + thin;              poly[2].y = y + size;
00150     poly[3].x = x + thin + gap;        poly[3].y = y + size;
00151     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
00152 }

Generated on Sun Mar 4 15:03:56 2007 for Scilab [trunk] by  doxygen 1.5.1