+ Flake.DB.b = window;
+ }
+
+ Flake.DisplayVar = dpy;
+ Flake.WindowVar = window;
+ Flake.Arms = get_integer_resource("arms", "Integer");
+ Flake.Thickness = get_integer_resource("thickness", "Integer");
+ Flake.BorderThickness = get_integer_resource("bthickness", "Integer");
+ Flake.Radius = get_integer_resource("radius", "Integer");
+
+ Flake.Density = get_integer_resource("density", "Integer");
+ Flake.Layers = get_integer_resource("layers", "Integer");
+ Flake.FallingSpeed = get_integer_resource("fallingspeed", "Integer");
+ Flake.Delay = get_integer_resource("delay", "Integer");
+ if (Flake.RandomColors == True)
+ Flake.RandomColors = get_boolean_resource("randomColors", "Boolean");
+
+ if (Flake.Delay < 0)
+ Flake.Delay = 0;
+
+ if (!Flake.Colors.Back)
+ {
+ Flake.Colors.Back = get_string_resource("color", "Color");
+ if (!FuzzyFlakesColorResource(Flake.Colors.Back))
+ {
+ fprintf(stderr, " reverting to random\n");
+ Flake.RandomColors = True;
+ }
+
+ if (Flake.RandomColors)
+ {
+ if (Flake.Colors.Back)
+ free(Flake.Colors.Back);
+ Flake.Colors.Back = malloc(sizeof(unsigned char) * 8);
+ sprintf(Flake.Colors.Back, "#%X%X%X%X%X%X", random() % 16,
+ random() % 16, random() % 16, random() % 16, random() % 16,
+ random() % 16);
+ }
+
+ /*
+ * Here we establish our colormap based on what is in
+ * Flake.Colors.Back
+ */
+ if (FuzzyFlakesColorHelper())
+ {
+ fprintf(stderr, " reverting to random\n");
+ if (Flake.Colors.Back)
+ free(Flake.Colors.Back);
+ Flake.Colors.Back = malloc(sizeof(unsigned char) * 8);
+ sprintf(Flake.Colors.Back, "#%X%X%X%X%X%X", random() % 16,
+ random() % 16, random() % 16, random() % 16, random() % 16,
+ random() % 16);
+ FuzzyFlakesColorHelper();
+ }
+
+ Flake.ForeColor = FuzzyFlakesColorResource(Flake.Colors.Fore);
+ Flake.BackColor = FuzzyFlakesColorResource(Flake.Colors.Back);
+ Flake.BordColor = FuzzyFlakesColorResource(Flake.Colors.Bord);
+
+ Flake.GCValues.foreground = Flake.ForeColor;
+ Flake.GCValues.background = Flake.BackColor;
+ Flake.RandomColors = False;
+ }
+
+ Flake.GCValues.line_width = Flake.Thickness;
+ Flake.GCValues.line_style = LineSolid;
+ Flake.GCValues.cap_style = CapProjecting;
+ Flake.GCValues.join_style = JoinMiter;
+ Flake.GCFlags |= (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle);
+
+ Flake.GCVar =
+ XCreateGC(Flake.DisplayVar, Flake.WindowVar, Flake.GCFlags,
+ &Flake.GCValues);
+
+ Flake.Density = Flake.XGWA.width / 200 * Flake.Density;
+ Flake.Flakes = malloc(sizeof(FlakeVariable **) * Flake.Layers);
+ for (i = 1; i <= Flake.Layers; i++)
+ {
+ Flake.Flakes[i - 1] = malloc(sizeof(FlakeVariable *) * Flake.Density);
+ for (j = 0; j < Flake.Density; j++)
+ {
+ Flake.Flakes[i - 1][j] = malloc(sizeof(FlakeVariable));
+ Flake.Flakes[i - 1][j]->XPos = random() % Flake.XGWA.width;
+ Flake.Flakes[i - 1][j]->YPos = random() % Flake.XGWA.height;
+ Flake.Flakes[i - 1][j]->Angle = random() % 360 * (M_PI / 180);
+ Flake.Flakes[i - 1][j]->Ticks = random() % 360;
+ Flake.Flakes[i - 1][j]->XOffset = random() % Flake.XGWA.height;
+ }
+ }
+}
+
+static void
+FuzzyFlakesFreeFlake(void)
+{
+ int i, j;
+
+ for (i = 1; i <= Flake.Layers; i++)
+ {
+ for (j = 0; j < Flake.Density; j++)
+ {
+ free(Flake.Flakes[i - 1][j]);
+ }
+ free(Flake.Flakes[i - 1]);
+ }
+
+ XFreePixmap(Flake.DisplayVar, Flake.DB.bb);
+ XFreePixmap(Flake.DisplayVar, Flake.DB.ba);
+}
+
+static void
+FuzzyFlakesResizeTest(void)
+{
+ XWindowAttributes xgwa;
+
+ XGetWindowAttributes(Flake.DisplayVar, Flake.WindowVar, &xgwa);
+ if (Flake.XGWA.width != xgwa.width || Flake.XGWA.height != xgwa.height)
+ {
+ FuzzyFlakesFreeFlake();
+ FuzzyFlakesInit(Flake.DisplayVar, Flake.WindowVar);