ftp://ftp.smr.ru/pub/0/FreeBSD/releases/distfiles/xscreensaver-3.16.tar.gz
[xscreensaver] / utils / xroger.c
1 /* xscreensaver, Copyright (c) 1991-1998 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  */
11
12 #include "utils.h"
13
14 static void
15 crossbones (Display *dpy, Window window, GC draw_gc,
16             int x, int y, int w, int h)
17 {
18   double xscale = w / 440.0;
19   double yscale = h / 216.0;
20   XPoint points [6];
21   points[0].x = x + xscale * 20;  points[0].y = y + yscale * 10;
22   points[1].x = x + xscale * 120; points[1].y = y + yscale * 10;
23   points[2].x = x + xscale * 243; points[2].y = y + yscale * 93;
24   points[3].x = x + xscale * 57;  points[3].y = y + yscale * 210;
25   points[4].x = x + xscale * 20;  points[4].y = y + yscale * 210;
26   points[5].x = x + xscale * 175; points[5].y = y + yscale * 113;
27   XFillPolygon (dpy, window, draw_gc, points, 6, Complex, CoordModeOrigin);
28   points[0].x = x + xscale * 202; points[0].y = y + yscale * 132;
29   points[1].x = x + xscale * 384; points[1].y = y + yscale * 10;
30   points[2].x = x + xscale * 420; points[2].y = y + yscale * 10;
31   points[3].x = x + xscale * 270; points[3].y = y + yscale * 113;
32   points[4].x = x + xscale * 420; points[4].y = y + yscale * 210;
33   points[5].x = x + xscale * 320; points[5].y = y + yscale * 210;
34   XFillPolygon (dpy, window, draw_gc, points, 6, Complex, CoordModeOrigin);
35 }
36
37
38 #include "spline.h"
39
40 void
41 skull (Display *dpy, Window window, GC draw_gc, GC erase_gc,
42        int x, int y, int w, int h)
43 {
44   spline s;
45   float w100, h100;
46   XPoint points [20];
47   double sx[20], sy[20];
48   int i;
49
50   memset(&s, 0, sizeof(s));
51   s.control_x = sx;
52   s.control_y = sy;
53
54   y -= (w * 0.025);
55
56   crossbones (dpy, window, draw_gc, x, y+(h/2), w, (h / 3));
57
58   x += (w * 0.27);
59   y += (h * 0.25);
60   w *= 0.6;
61   h *= 0.6;
62
63   w100 = w / 100.0;
64   h100 = h / 100.0;
65
66   points[ 0].x = x + (0   * w100); points[ 0].y = y + (10 * h100);
67   points[ 1].x = x + (10  * w100); points[ 1].y = y + (0  * h100);
68   points[ 2].x = x + (90  * w100); points[ 2].y = y + (0  * h100);
69   points[ 3].x = x + (100 * w100); points[ 3].y = y + (10 * h100);
70   points[ 4].x = x + (100 * w100); points[ 4].y = y + (30 * h100);
71   points[ 5].x = x + (90  * w100); points[ 5].y = y + (40 * h100);
72   points[ 6].x = x + (70  * w100); points[ 6].y = y + (40 * h100);
73   points[ 7].x = x + (70  * w100); points[ 7].y = y + (50 * h100);
74   points[ 8].x = x + (30  * w100); points[ 8].y = y + (50 * h100);
75   points[ 9].x = x + (30  * w100); points[ 9].y = y + (40 * h100);
76   points[10].x = x + (10  * w100); points[10].y = y + (40 * h100);
77   points[11].x = x + (0   * w100); points[11].y = y + (30 * h100);
78
79   for (i = 0; i < 12; i++)
80     sx[i] = points[i].x, sy[i] = points[i].y;
81   s.n_controls = i;
82   s.allocated_points = i;
83   s.points = (XPoint *) calloc (i, sizeof (*s.points));
84   compute_closed_spline(&s);
85
86   XFillPolygon (dpy, window, draw_gc, points+6, 4, Complex, CoordModeOrigin);
87   XFillPolygon (dpy, window, draw_gc, s.points, s.n_points,
88                 Complex, CoordModeOrigin);
89
90   points[0].x = x + (20  * w100); points[0].y = y + (18 * h100);
91   points[1].x = x + (25  * w100); points[1].y = y + (15 * h100);
92   points[2].x = x + (43  * w100); points[2].y = y + (15 * h100);
93   points[3].x = x + (45  * w100); points[3].y = y + (17 * h100);
94   points[4].x = x + (45  * w100); points[4].y = y + (25 * h100);
95   points[5].x = x + (40  * w100); points[5].y = y + (30 * h100);
96   points[6].x = x + (30  * w100); points[6].y = y + (30 * h100);
97   points[7].x = x + (20  * w100); points[7].y = y + (23 * h100);
98   for (i = 0; i < 8; i++)
99     sx[i] = points[i].x, sy[i] = points[i].y;
100   s.n_controls = i;
101   compute_closed_spline(&s);
102   XFillPolygon (dpy, window, erase_gc, s.points, s.n_points,
103                 Complex, CoordModeOrigin);
104
105   points[0].x = x + (80  * w100); points[0].y = y + (18 * h100);
106   points[1].x = x + (75  * w100); points[1].y = y + (15 * h100);
107   points[2].x = x + (57  * w100); points[2].y = y + (15 * h100);
108   points[3].x = x + (55  * w100); points[3].y = y + (17 * h100);
109   points[4].x = x + (55  * w100); points[4].y = y + (25 * h100);
110   points[5].x = x + (60  * w100); points[5].y = y + (30 * h100);
111   points[6].x = x + (70  * w100); points[6].y = y + (30 * h100);
112   points[7].x = x + (80  * w100); points[7].y = y + (23 * h100);
113   for (i = 0; i < 8; i++)
114     sx[i] = points[i].x, sy[i] = points[i].y;
115   s.n_controls = i;
116   compute_closed_spline(&s);
117   XFillPolygon (dpy, window, erase_gc, s.points, s.n_points,
118                 Complex, CoordModeOrigin);
119
120   points[ 0].x = x + (48  * w100); points[ 0].y = y + (30 * h100);
121   points[ 1].x = x + (52  * w100); points[ 1].y = y + (30 * h100);
122   points[ 2].x = x + (56  * w100); points[ 2].y = y + (42 * h100);
123   points[ 3].x = x + (52  * w100); points[ 3].y = y + (45 * h100);
124   points[ 4].x = x + (48  * w100); points[ 4].y = y + (45 * h100);
125   points[ 5].x = x + (44  * w100); points[ 5].y = y + (42 * h100);
126   for (i = 0; i < 6; i++)
127     sx[i] = points[i].x, sy[i] = points[i].y;
128   s.n_controls = i;
129   compute_closed_spline(&s);
130   XFillPolygon (dpy, window, erase_gc, s.points, s.n_points,
131                 Complex, CoordModeOrigin);
132
133   free(s.points);
134 }