diff options
-rw-r--r-- | flam3.c | 23 | ||||
-rw-r--r-- | flam3.h | 2 | ||||
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | parser.c | 2 |
4 files changed, 10 insertions, 24 deletions
@@ -1320,34 +1320,15 @@ static int compare_xforms(const void *av, const void *bv) { } /* sym=2 or more means rotational - sym=1 means identity, ie no symmetry - sym=0 means pick a random symmetry (maybe none) + sym=1 and sym=0 means identity, ie no symmetry sym=-1 means bilateral (reflection) sym=-2 or less means rotational and reflective */ -void flam3_add_symmetry(flam3_genome *cp, int sym, randctx * const rc) { +void flam3_add_symmetry(flam3_genome *cp, int sym) { int i, j, k; double a; int result = 0; - if (0 == sym) { - static int sym_distrib[] = { - -4, -3, - -2, -2, -2, - -1, -1, -1, - 2, 2, 2, - 3, 3, - 4, 4, - }; - if (rand_bool(rc)) { - sym = rand_distrib(rc, sym_distrib); - } else if (rand_mod(rc, 32)) { - sym = rand_mod(rc, 13)-6; - } else { - sym = rand_mod(rc, 51)-25; - } - } - if (1 == sym || 0 == sym) return; cp->symmetry = sym; @@ -457,7 +457,7 @@ void flam3_cross(flam3_genome *cp0, flam3_genome *cp1, flam3_genome *out, int cr /* return NULL in case of error */ flam3_genome *flam3_parse_xml2(const int, int default_flag, int *ncps, randctx * const); -void flam3_add_symmetry(flam3_genome *cp, int sym, randctx * const rc); +void flam3_add_symmetry(flam3_genome *cp, int sym); void flam3_improve_colors(flam3_genome *g, unsigned int ntries, bool change_palette, @@ -145,6 +145,7 @@ static void print_genome (flam3_genome * const genome) { typedef struct { const char *palette; unsigned int width, height, max_xforms, max_var; + signed int max_symmetry, min_symmetry; double post_likelihood, final_likelihood, symmetry_likelihood; } random_arguments; @@ -277,7 +278,9 @@ static void do_random (const random_arguments * const arguments) { /* Randomly add symmetry (but not if we've already added a final xform) */ if (rand_d01(&rc) < arguments->symmetry_likelihood && !add_final) { - flam3_add_symmetry(&genome, 0, &rc); + assert (arguments->max_symmetry >= arguments->min_symmetry); + unsigned int symrange = arguments->max_symmetry - arguments->min_symmetry + 1; + flam3_add_symmetry(&genome, rand_mod (&rc, symrange) + arguments->min_symmetry); } /* random resets genome, adjust before finding appropriate bbox */ @@ -635,6 +638,8 @@ int main (int argc, char **argv) { .post_likelihood = 0.4, .final_likelihood = 0.15, .symmetry_likelihood = 0.25, + .min_symmetry = -6, + .max_symmetry = 6, }; argp_parse (&argp, argc, argv, 0, NULL, &arguments); @@ -603,7 +603,7 @@ static int parse_flame_element(xmlNode *flame_node, flam3_genome *loc_current_cp } bef = cp->num_xforms; - flam3_add_symmetry(cp,kind, rc); + flam3_add_symmetry(cp, kind); aft = cp->num_xforms; num_std_xforms += (aft-bef); |