1 /*
2 
3 Copyright 1988, 1998  The Open Group
4 
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10 
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13 
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24 
25 */
26 
27 #ifdef HAVE_CONFIG_H
28 #include <config.h>
29 #endif
30 #include <X11/Xlib.h>
31 #include <X11/Xmu/Drawing.h>
32 
33 /*
34  *  Draw the "official" X Window System Logo, designed by Danny Chong
35  *
36  *  Written by Ollie Jones, Apollo Computer
37  *
38  *  Does some fancy stuff to make the logo look acceptable even
39  *  if it is tiny.  Also makes the various linear elements of
40  *  the logo line up as well as possible considering rasterization.
41  */
42 void
XmuDrawLogo(Display * dpy,Drawable drawable,GC gcFore,GC gcBack,int x,int y,unsigned int width,unsigned int height)43 XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack,
44 	    int x, int y, unsigned int width, unsigned int height)
45 {
46     unsigned int size;
47     int thin, gap, d31;
48     XPoint poly[4];
49 
50     XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
51 
52     /* for now, do a centered even-sized square, at least for now */
53     size = width;
54     if (height < width)
55 	 size = height;
56     size &= ~1;
57     x += (width - size) >> 1;
58     y += (height - size) >> 1;
59 
60 /*
61  * Draw what will be the thin strokes.
62  *
63  *           -----
64  *          /    /
65  *         /    /
66  *        /    /
67  *       /    /
68  *      /____/
69  *           d
70  *
71  * Point d is 9/44 (~1/5) of the way across.
72  */
73 
74     thin = (size / 11);
75     if (thin < 1) thin = 1;
76     gap = (thin+3) / 4;
77     d31 = thin + thin + gap;
78     poly[0].x = x + size;              poly[0].y = y;
79     poly[1].x = x + size-d31;          poly[1].y = y;
80     poly[2].x = x + 0;                 poly[2].y = y + size;
81     poly[3].x = x + d31;               poly[3].y = y + size;
82     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
83 
84 /*
85  * Erase area not needed for lower thin stroke.
86  *
87  *           ------
88  *          /     /
89  *         /  __ /
90  *        /  /  /
91  *       /  /  /
92  *      /__/__/
93  */
94 
95     poly[0].x = x + d31/2;                       poly[0].y = y + size;
96     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
97     poly[2].x = x + (size/2)+(d31-(d31/2));      poly[2].y = y + size/2;
98     poly[3].x = x + d31;                         poly[3].y = y + size;
99     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
100 
101 /*
102  * Erase area not needed for upper thin stroke.
103  *
104  *           ------
105  *          /  /  /
106  *         /--/  /
107  *        /     /
108  *       /     /
109  *      /_____/
110  */
111 
112     poly[0].x = x + size - d31/2;                poly[0].y = y;
113     poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
114     poly[2].x = x + (size/2)-(d31-(d31/2));      poly[2].y = y + size/2;
115     poly[3].x = x + size - d31;                  poly[3].y = y;
116     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
117 
118 /*
119  * Draw thick stroke.
120  * Point b is 1/4 of the way across.
121  *
122  *      b
123  * -----
124  * \    \
125  *  \    \
126  *   \    \
127  *    \    \
128  *     \____\
129  */
130 
131     poly[0].x = x;                     poly[0].y = y;
132     poly[1].x = x + size/4;            poly[1].y = y;
133     poly[2].x = x + size;              poly[2].y = y + size;
134     poly[3].x = x + size - size/4;     poly[3].y = y + size;
135     XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
136 
137 /*
138  * Erase to create gap.
139  *
140  *          /
141  *         /
142  *        /
143  *       /
144  *      /
145  */
146 
147     poly[0].x = x + size- thin;        poly[0].y = y;
148     poly[1].x = x + size-( thin+gap);  poly[1].y = y;
149     poly[2].x = x + thin;              poly[2].y = y + size;
150     poly[3].x = x + thin + gap;        poly[3].y = y + size;
151     XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
152 }
153