-#define PROGCLASS "Penrose"
-#define HACK_INIT init_penrose
-#define HACK_DRAW draw_penrose
-#define penrose_opts xlockmore_opts
-#define DEFAULTS "*delay: 10000 \n" \
- "*size: 40 \n" \
- "*ncolors: 64 \n"
-#include "xlockmore.h" /* from the xscreensaver distribution */
+#define DEFAULTS "*delay: 10000 \n" \
+ "*size: 40 \n" \
+ "*ncolors: 64 \n" \
+ "*fpsSolid: true \n" \
+ "*ignoreRotation: True \n" \
+
+# define release_penrose 0
+# define penrose_handle_event 0
+# include "xlockmore.h" /* from the xscreensaver distribution */
- {(char *) "-ammann", (char *) ".penrose.ammann", XrmoptionNoArg, (caddr_t) "on"},
- {(char *) "+ammann", (char *) ".penrose.ammann", XrmoptionNoArg, (caddr_t) "off"}
+ {"-ammann", ".penrose.ammann", XrmoptionNoArg, "on"},
+ {"+ammann", ".penrose.ammann", XrmoptionNoArg, "off"}
- {(caddr_t *) & ammann, (char *) "ammann", (char *) "Ammann", (char *) DEF_AMMANN, t_Bool}
+ {&ammann, "ammann", "Ammann", DEF_AMMANN, t_Bool}
{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
#ifdef USE_MODULES
ModStruct penrose_description =
{sizeof opts / sizeof opts[0], opts, sizeof vars / sizeof vars[0], vars, desc};
#ifdef USE_MODULES
ModStruct penrose_description =
-{"penrose", "init_penrose", "draw_penrose", "release_penrose",
- "init_penrose", "init_penrose", (char *) NULL, &penrose_opts,
+{"penrose", "init_penrose", "draw_penrose", (char *) NULL,
+ "init_penrose", "init_penrose", "free_penrose", &penrose_opts,
10000, 1, 1, -40, 64, 1.0, "",
"Shows Penrose's quasiperiodic tilings", 0, NULL};
10000, 1, 1, -40, 64, 1.0, "",
"Shows Penrose's quasiperiodic tilings", 0, NULL};
+/* This is the data related to the tiling of one screen. */
+typedef struct {
+ int width, height;
+ XPoint origin;
+ int edge_length, line_width;
+ fringe_c fringe;
+ forced_pool_c forced;
+ int done, failures;
+ unsigned long thick_color, thin_color;
+ int busyLoop;
+ Bool ammann;
+ float ammann_r;
+ fcoord_c fived_table[5];
+} tiling_c;
+
+static tiling_c *tilings = (tiling_c *) NULL;
+
+
+
/* Direction angle of an edge. */
static angle_c
vertex_dir(ModeInfo * mi, fringe_node_c * vertex, unsigned side)
/* Direction angle of an edge. */
static angle_c
vertex_dir(ModeInfo * mi, fringe_node_c * vertex, unsigned side)
register fringe_node_c *fp1, *fp2;
register forced_node_c *lp1, *lp2;
register fringe_node_c *fp1, *fp2;
register forced_node_c *lp1, *lp2;
tp = &tilings[MI_SCREEN(mi)];
#if 0 /* if you do this, then the -ammann and -no-ammann options don't work.
tp = &tilings[MI_SCREEN(mi)];
#if 0 /* if you do this, then the -ammann and -no-ammann options don't work.
if (size < -MINSIZE)
tp->edge_length = NRAND(MIN(-size, MAX(MINSIZE,
MIN(tp->width, tp->height) / 2)) - MINSIZE + 1) + MINSIZE;
if (size < -MINSIZE)
tp->edge_length = NRAND(MIN(-size, MAX(MINSIZE,
MIN(tp->width, tp->height) / 2)) - MINSIZE + 1) + MINSIZE;
if (tp->fringe.nodes != NULL || tp->forced.first != 0) {
if (MI_IS_VERBOSE(mi)) {
(void) fprintf(stderr, "Weirdness in init_penrose()\n");
(void) fprintf(stderr, "tp->fringe.nodes = NULL && tp->forced.first = 0\n");
}
if (tp->fringe.nodes != NULL || tp->forced.first != 0) {
if (MI_IS_VERBOSE(mi)) {
(void) fprintf(stderr, "Weirdness in init_penrose()\n");
(void) fprintf(stderr, "tp->fringe.nodes = NULL && tp->forced.first = 0\n");
}
tp->done = True;
}
tp->forced.n_nodes = tp->forced.n_visible = 0;
if ((fp = tp->fringe.nodes = ALLOC_NODE(fringe_node_c)) == NULL) {
tp->done = True;
}
tp->forced.n_nodes = tp->forced.n_visible = 0;
if ((fp = tp->fringe.nodes = ALLOC_NODE(fringe_node_c)) == NULL) {
(void) fprintf(stderr, "fp = 0\n");
}
if ((fp = tp->fringe.nodes = ALLOC_NODE(fringe_node_c)) == NULL) {
(void) fprintf(stderr, "fp = 0\n");
}
if ((fp = tp->fringe.nodes = ALLOC_NODE(fringe_node_c)) == NULL) {
fp->rule_mask = (1 << N_VERTEX_RULES) - 1;
fp->list_ptr = 0;
if ((fp->prev = fp->next = ALLOC_NODE(fringe_node_c)) == NULL) {
fp->rule_mask = (1 << N_VERTEX_RULES) - 1;
fp->list_ptr = 0;
if ((fp->prev = fp->next = ALLOC_NODE(fringe_node_c)) == NULL) {
(void) fprintf(stderr, "fp->next = 0\n");
}
if ((fp->prev = fp->next = ALLOC_NODE(fringe_node_c)) == NULL) {
(void) fprintf(stderr, "fp->next = 0\n");
}
if ((fp->prev = fp->next = ALLOC_NODE(fringe_node_c)) == NULL) {
fp->fived[i] = 2 * NRAND(2) - 1;
fived_to_loc(fp->fived, tp, &(fp->loc));
/* That's it! We have created our first edge. */
fp->fived[i] = 2 * NRAND(2) - 1;
fived_to_loc(fp->fived, tp, &(fp->loc));
/* That's it! We have created our first edge. */
XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
XFillPolygon(display, window, gc, pts, 4, Convex, CoordModeOrigin);
XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
XFillPolygon(display, window, gc, pts, 4, Convex, CoordModeOrigin);
XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
XDrawLines(display, window, gc, pts, 5, CoordModeOrigin);
if (tp->ammann) {
XDrawLines(display, window, gc, pts, 5, CoordModeOrigin);
if (tp->ammann) {
}
if (MI_NPIXELS(mi) > 2)
XSetForeground(display, gc, MI_PIXEL(mi, tp->thin_color));
}
if (MI_NPIXELS(mi) > 2)
XSetForeground(display, gc, MI_PIXEL(mi, tp->thin_color));
XSetLineAttributes(display, gc, 1, LineOnOffDash, CapNotLast, JoinMiter);
}
XDrawLine(display, window, gc,
XSetLineAttributes(display, gc, 1, LineOnOffDash, CapNotLast, JoinMiter);
}
XDrawLine(display, window, gc,
- (int) (r * pts[3].x + (1 - r) * pts[0].x + .5),
- (int) (r * pts[3].y + (1 - r) * pts[0].y + .5),
- (int) (r * pts[1].x + (1 - r) * pts[0].x + .5),
- (int) (r * pts[1].y + (1 - r) * pts[0].y + .5));
+ (int) (tp->ammann_r * pts[3].x + (1 - tp->ammann_r) * pts[0].x + .5),
+ (int) (tp->ammann_r * pts[3].y + (1 - tp->ammann_r) * pts[0].y + .5),
+ (int) (tp->ammann_r * pts[1].x + (1 - tp->ammann_r) * pts[0].x + .5),
+ (int) (tp->ammann_r * pts[1].y + (1 - tp->ammann_r) * pts[0].y + .5));
if (MI_NPIXELS(mi) <= 2)
XSetLineAttributes(display, gc, 1, LineSolid, CapNotLast, JoinMiter);
} else {
if (MI_NPIXELS(mi) <= 2)
XSetLineAttributes(display, gc, 1, LineSolid, CapNotLast, JoinMiter);
} else {
fived_to_loc(v->fived, tp, &(v->loc));
if (v->loc.x < 0 || v->loc.y < 0
|| v->loc.x >= tp->width || v->loc.y >= tp->height) {
fived_to_loc(v->fived, tp, &(v->loc));
if (v->loc.x < 0 || v->loc.y < 0
|| v->loc.x >= tp->width || v->loc.y >= tp->height) {
if (tp->fringe.nodes->prev == tp->fringe.nodes->next) {
vertex_type_c vtype = (unsigned char) (VT_TOTAL_MASK & LRAND());
if (tp->fringe.nodes->prev == tp->fringe.nodes->next) {
vertex_type_c vtype = (unsigned char) (VT_TOTAL_MASK & LRAND());
if (!add_tile(mi, tp->fringe.nodes, S_LEFT, vtype))
if (!add_tile(mi, tp->fringe.nodes, S_LEFT, vtype))
- if (tilings != NULL) {
- int screen;
-
- for (screen = 0; screen < MI_NUM_SCREENS(mi); screen++)
- free_penrose(&tilings[screen]);
- (void) free((void *) tilings);
- tilings = (tiling_c *) NULL;
- }
+ tiling_c *tp = &tilings[MI_SCREEN(mi)];
+ tp->width = width;
+ tp->height = height;