- XGetWindowAttributes(dpy, window, &wa);
- mx = wa.width - 1;
- my = wa.height - 1;
- mp = cPoint - 1;
-
- aWork[0] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- aWork[1] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- aTmp = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
-
-
- /*
- * Figure 0
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- s = cPoint / 4;
- for (q = 0; q < s; q++) {
- a[cFig][q].x = ((double) q / s) * mx;
- a[cFig][q].y = 0;
- a[cFig][s + q].x = mx;
- a[cFig][s + q].y = ((double) q / s) * my;
- a[cFig][2 * s + q].x = mx - ((double) q / s) * mx;
- a[cFig][2 * s + q].y = my;
- a[cFig][3 * s + q].x = 0;
- a[cFig][3 * s + q].y = my - ((double) q / s) * my;
- }
- for (q = 4 * s; q < cPoint; q++)
- a[cFig][q].x = a[cFig][q].y = 0;
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 1
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = ((double) q / cPoint) * mx;
- a[cFig][q].y = (1.0 - sin(((double) q / mp) * TWO_PI)) * my / 2.0;
- }
- ++cFig;
-
- /*
- * Figure 2
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + rx * sin(1 * TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 3
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * sin(3 * TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * cos(1 * TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 4
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * (1 - 0.1 * frnd())
- * sin(TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * (1 - 0.1 * frnd())
- * cos(TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 5
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
- * sin(TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
- * cos(TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 6
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * sin(TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * cos(TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 7
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + rx * cos(TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * sin(TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 8
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = ((double) q / mp) * mx;
- a[cFig][q].y = (1.0 - cos(((double) q / mp) * 3 * TWO_PI)) * my / 2.0;
- }
- ++cFig;
-
- /*
- * Figure 9
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + rx * sin(2 * TWO_PI * (double) q / mp);
- a[cFig][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
- }
- a[cFig][mp].x = a[cFig][0].x;
- a[cFig][mp].y = a[cFig][0].y;
- ++cFig;
-
- /*
- * Figure 10
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * sin(5 * TWO_PI * (double) q / mp)
- * ((double) q / mp);
- a[cFig][q].y = my / 2 + ry * cos(5 * TWO_PI * (double) q / mp)
- * ((double) q / mp);
- }
- ++cFig;
-
- /*
- * Figure 11
- */
- a[cFig] = (XPoint *) xmalloc(cPoint * sizeof(XPoint));
- rx = mx / 2;
- ry = my / 2;
- for (q = 0; q < cPoint; q++) {
- a[cFig][q].x = mx / 2 + ry * sin(6 * TWO_PI * (double) q / mp)
- * ((double) q / mp);
- a[cFig][q].y = my / 2 - ry * cos(6 * TWO_PI * (double) q / mp)
- * ((double) q / mp);
+ mx = scrWidth - 1;
+ my = scrHeight - 1;
+ mp = numPoints - 1;
+
+ aWork[0] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ aWork[1] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ aTmp = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+
+ if (figType & FT_CLOSED) {
+ /* rectangle */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ s = numPoints / 4;
+ for (q = 0; q < s; q++) {
+ a[numFigs][q].x = ((double) q / s) * mx;
+ a[numFigs][q].y = 0;
+ a[numFigs][s + q].x = mx;
+ a[numFigs][s + q].y = ((double) q / s) * my;
+ a[numFigs][2 * s + q].x = mx - ((double) q / s) * mx;
+ a[numFigs][2 * s + q].y = my;
+ a[numFigs][3 * s + q].x = 0;
+ a[numFigs][3 * s + q].y = my - ((double) q / s) * my;
+ }
+ for (q = 4 * s; q < numPoints; q++)
+ a[numFigs][q].x = a[numFigs][q].y = 0;
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + rx * sin(1 * TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + ry * sin(3 * TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry * cos(1 * TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + ry
+ * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+ * sin(TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry
+ * (0.8 - 0.2 * sin(30 * TWO_PI * q / mp))
+ * cos(TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + ry * sin(TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry * cos(TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + rx * cos(TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry * sin(TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;
+
+ /* */
+ a[numFigs] = (XPoint *) xmalloc(numPoints * sizeof(XPoint));
+ rx = mx / 2;
+ ry = my / 2;
+ for (q = 0; q < numPoints; q++) {
+ a[numFigs][q].x = mx / 2 + rx * sin(2 * TWO_PI * (double) q / mp);
+ a[numFigs][q].y = my / 2 + ry * cos(3 * TWO_PI * (double) q / mp);
+ }
+ a[numFigs][mp].x = a[numFigs][0].x;
+ a[numFigs][mp].y = a[numFigs][0].y;
+ ++numFigs;