various updates

git-svn-id: https://flam3.googlecode.com/svn/trunk@165 77852712-ef1d-11de-8684-7d64432d61a3
This commit is contained in:
Scott Draves 2015-02-15 16:24:13 +00:00
parent fb1c90e18b
commit d29fd65614
7 changed files with 162 additions and 23 deletions

View File

@ -5,7 +5,7 @@
#define HAVE_DLFCN_H 1
/* Have 64-bit __sync_bool_compare_and_swap() and friends. */
/* #undef HAVE_GCC_64BIT_ATOMIC_OPS */
#define HAVE_GCC_64BIT_ATOMIC_OPS 1
/* Have 32-bit __sync_bool_compare_and_swap() and friends. */
#define HAVE_GCC_ATOMIC_OPS 1

View File

@ -51,6 +51,7 @@ void test_cp(flam3_genome *cp) {
cp->spatial_oversample = 1;
cp->spatial_filter_radius = 0.5;
cp->spatial_filter_select = 0;
cp->highlight_power= 1.0;
cp->zoom = 0.0;
cp->sample_density = 1;
cp->nbatches = 1;
@ -60,7 +61,7 @@ void test_cp(flam3_genome *cp) {
cp->estimator_curve = 0.6;
}
flam3_genome *string_to_cp(char *s, int *n) {
flam3_genome *string_to_cp(char *s, int *n, int defaults) {
flam3_genome *cp;
FILE *fp;
@ -69,7 +70,7 @@ flam3_genome *string_to_cp(char *s, int *n) {
perror(s);
exit(1);
}
cp = flam3_parse_from_file(fp, s, flam3_defaults_on, n);
cp = flam3_parse_from_file(fp, s, defaults, n);
if (NULL == cp) {
fprintf(stderr, "could not read genome from %s.\n", s);
exit(1);
@ -89,6 +90,7 @@ xmlDocPtr create_new_editdoc(char *action, flam3_genome *parent0, flam3_genome *
char *nick = getenv("nick");
char *url = getenv("url");
char *id = getenv("id");
char *gen = getenv("gen");
char *comment = getenv("comment");
int sheep_gen = argi("sheep_gen",-1);
int sheep_id = argi("sheep_id",-1);
@ -123,6 +125,10 @@ xmlDocPtr create_new_editdoc(char *action, flam3_genome *parent0, flam3_genome *
xmlNewProp(root_node, (const xmlChar *)"id", (const xmlChar *)id);
}
if (gen) {
xmlNewProp(root_node, (const xmlChar *)"gen", (const xmlChar *)gen);
}
/* action */
xmlNewProp(root_node, (const xmlChar *)"action", (const xmlChar *)action);
@ -373,6 +379,58 @@ static double golden_bit(randctx *rc) {
return flam3_random_isaac_bit(rc)?0.38196:0.61804;
}
static void print_find_parents(xmlNode *node, int last, int level) {
xmlAttrPtr att_ptr, cur_att;
xmlNodePtr chld_ptr=NULL, cur_chld=NULL;
xmlNode *this_node;
int i;
int next_last;
//for (i = 0; i < level; i++)
// fprintf(stdout, "+");
// fprintf(stdout, "pfp %d ", last);
for (this_node=node; this_node; this_node = this_node->next) {
if (this_node->type == XML_ELEMENT_NODE) {
// fprintf(stdout, "nname=%s ", this_node->name);
if (!xmlStrcmp(this_node->name, (const xmlChar *)"edit")) {
att_ptr = node->properties;
next_last = 0;
if (last) {
char *pgen = NULL, *pid = NULL;
for (cur_att = att_ptr; cur_att; cur_att = cur_att->next) {
if (!xmlStrcmp(cur_att->name, (const xmlChar *)"gen")) {
char *att_str = (char *) xmlGetProp(node,cur_att->name);
pgen = att_str;
}
if (!xmlStrcmp(cur_att->name, (const xmlChar *)"id")) {
char *att_str = (char *) xmlGetProp(node,cur_att->name);
pid = att_str;
}
}
if (pgen) printf("GEN=%s ", pgen);
if (pid) printf("ID=%s", pid);
if (pid || pgen)
printf("\n");
} else {
for (cur_att = att_ptr; cur_att; cur_att = cur_att->next) {
char *att_str = (char *) xmlGetProp(node,cur_att->name);
// fprintf(stdout, "name=%s val=%s ", cur_att->name, att_str);
if (!xmlStrcmp(cur_att->name, (const xmlChar *)"action")) {
if (!strncmp(att_str, "cross", 5) || !strncmp(att_str, "mutate", 6)) {
next_last = 1;
}
}
}
// fprintf(stdout, "\n");
chld_ptr = node->children;
for (cur_chld=chld_ptr; cur_chld; cur_chld = cur_chld->next)
print_find_parents(cur_chld, next_last, level + 1);
}
}
}
return;
}
}
int
main(argc, argv)
int argc;
@ -400,6 +458,7 @@ main(argc, argv)
char *cross1 = getenv("cross1");
char *method = getenv("method");
char *inter = getenv("inter");
char *find_parents = getenv("find_parents");
char *rotate = getenv("rotate");
char *strip = getenv("strip");
char *sequence = getenv("sequence");
@ -599,7 +658,7 @@ main(argc, argv)
if (getenv("template")) {
char *tf = getenv("template");
templ = string_to_cp(tf, &ncp);
templ = string_to_cp(tf, &ncp, flam3_defaults_off);
if (1 < ncp) {
fprintf(stderr, "more than one control point in template, "
"ignoring all but first.\n");
@ -614,7 +673,7 @@ main(argc, argv)
if (clone_all) {
cp = string_to_cp(clone_all, &ncp);
cp = string_to_cp(clone_all, &ncp, flam3_defaults_on);
printf("<clone_all version=\"FLAM3-%s\">\n", flam3_version());
for (i = 0; i < ncp; i++) {
@ -632,7 +691,7 @@ main(argc, argv)
int first_frame,last_frame;
int ftime,iscp;
double stagger = argf("stagger", 0.0);
cp = string_to_cp(animate, &ncp);
cp = string_to_cp(animate, &ncp, flam3_defaults_on);
for (i = 0; i < ncp; i++) {
@ -698,7 +757,7 @@ main(argc, argv)
exit(1);
}
cp = string_to_cp(sequence, &ncp);
cp = string_to_cp(sequence, &ncp, flam3_defaults_on);
if (enclosed) printf("<sequence version=\"FLAM3-%s\">\n", flam3_version());
spread = 1.0/nframes;
@ -762,7 +821,7 @@ main(argc, argv)
blend = frame/(double)nframes;
spread = 1.0/nframes;
cp = string_to_cp(fname, &ncp);
cp = string_to_cp(fname, &ncp, flam3_defaults_on);
if (enclosed) printf("<pick version=\"FLAM3-%s\">\n", flam3_version());
if (rotate) {
@ -795,7 +854,7 @@ main(argc, argv)
if (strip) {
cp = string_to_cp(strip, &ncp);
cp = string_to_cp(strip, &ncp, flam3_defaults_on);
if (enclosed) printf("<pick version=\"FLAM3-%s\">\n", flam3_version());
@ -823,6 +882,18 @@ main(argc, argv)
exit(0);
}
if (find_parents) {
cp = string_to_cp(find_parents, &ncp, flam3_defaults_on);
if (1 != ncp) {
fprintf(stderr, "can only find parents of one genome\n");
exit(1);
}
xmlDocPtr edits = cp[0].edits;
xmlNode *rootnode = xmlDocGetRootElement(edits);
print_find_parents(rootnode, 0, 0);
exit(0);
}
/* pick a control point until it looks good enough */
if (repeat <= 0) {
fprintf(stderr, "repeat must be positive, not %d.\n", repeat);
@ -841,7 +912,7 @@ main(argc, argv)
if (clone) {
parent0 = string_to_cp(clone, &parent0_n);
parent0 = string_to_cp(clone, &parent0_n, flam3_defaults_on);
/* Action is 'clone' with trunc_vars concat */
sprintf(action,"clone");
@ -871,7 +942,7 @@ main(argc, argv)
if (mutate) {
int mutmeth;
parent0 = string_to_cp(mutate, &parent0_n);
parent0 = string_to_cp(mutate, &parent0_n, flam3_defaults_on);
flam3_copy(&selp0, &(parent0[((unsigned)irand(&f.rc))%parent0_n]));
flam3_copy(&cp_orig, &selp0);
aselp0 = &selp0;
@ -914,8 +985,8 @@ main(argc, argv)
int i0, i1;
int crossmeth;
parent0 = string_to_cp(cross0, &parent0_n);
parent1 = string_to_cp(cross1, &parent1_n);
parent0 = string_to_cp(cross0, &parent0_n, flam3_defaults_on);
parent1 = string_to_cp(cross1, &parent1_n, flam3_defaults_on);
i0 = ((unsigned)irand(&f.rc))%parent0_n;
i1 = ((unsigned)irand(&f.rc))%parent1_n;

View File

@ -480,6 +480,8 @@ flam3_genome *sheep_edge(flam3_genome *cp, double blend, int seqflag, double sta
flam3_rotate(&spun[0], blend*360.0, spun[0].interpolation_type);
flam3_rotate(&spun[1], blend*360.0, spun[0].interpolation_type);
fprintf(stderr, "xyzzy %d %d\n", spun[0].palette_interpolation, spun[1].palette_interpolation);
/* Now call the interpolation */
if (argi("unsmoother",0) == 0)
flam3_interpolate(spun, 2, smoother(blend), stagger, result);
@ -1580,7 +1582,8 @@ void flam3_apply_template(flam3_genome *cp, flam3_genome *templ) {
cp->ntemporal_samples = templ->ntemporal_samples;
if (templ->width > 0) {
/* preserving scale should be an option */
cp->pixels_per_unit = cp->pixels_per_unit * templ->width / cp->width;
// cp->pixels_per_unit = cp->pixels_per_unit * templ->width / cp->width;
cp->pixels_per_unit = cp->pixels_per_unit * templ->height / cp->height;
cp->width = templ->width;
}
if (templ->height > 0)
@ -1613,6 +1616,8 @@ void flam3_apply_template(flam3_genome *cp, flam3_genome *templ) {
cp->highlight_power = templ->highlight_power;
if (templ->palette_mode >= 0)
cp->palette_mode = templ->palette_mode;
if (templ->palette_interpolation >= 0)
cp->palette_interpolation = templ->palette_interpolation;
}
@ -1777,8 +1782,12 @@ void flam3_print(FILE *f, flam3_genome *cp, char *extra_attributes, int print_ed
fprintf(f, " interpolation_type=\"older\"");
if (flam3_palette_interpolation_hsv != cp->palette_interpolation)
if (flam3_palette_interpolation_sweep == cp->palette_interpolation)
fprintf(f, " palette_interpolation=\"sweep\"");
else if (flam3_palette_interpolation_rgb == cp->palette_interpolation)
fprintf(f, " palette_interpolation=\"rgb\"");
else if (flam3_palette_interpolation_hsv2 == cp->palette_interpolation)
fprintf(f, " palette_interpolation=\"hsv2\"");
if (extra_attributes)
fprintf(f, " %s", extra_attributes);
@ -1930,6 +1939,7 @@ void flam3_print_xform(FILE *f, flam3_xform *x, int final_flag, int numstd, doub
for (j = 0; j < lnv; j++) {
double v = x->var[j];
if (j == VAR_TWINTRIAN) continue;
if (0.0 != v) {
fprintf(f, "%s=\"%g\" ", flam3_variation_names[j], v);
if (j==VAR_BLOB)

View File

@ -74,6 +74,8 @@ extern char *flam3_variation_names[];
#define flam3_palette_interpolation_hsv 0
#define flam3_palette_interpolation_sweep 1
#define flam3_palette_interpolation_rgb 2
#define flam3_palette_interpolation_hsv2 3
#define flam3_max_action_length 10000

View File

@ -170,6 +170,15 @@ void interpolate_cmap(flam3_palette cmap, double blend,
s[4] = p0[i].index;
t[4] = p1[i].index;
/* take the shorter way around the hue circle */
if (0 == i) {
fprintf(stderr, "xxx interpolating between hues, %g %g\n", s[0], t[0]);
}
if ((s[0] - t[0]) > 3.0)
s[0] += 6.0;
if ((t[0] - s[0]) > 3.0)
t[0] += 6.0;
for (j = 0; j < 5; j++)
t[j] = ((1.0-blend) * s[j]) + (blend * t[j]);
@ -362,17 +371,44 @@ double get_stagger_coef(double t, double stagger_prc, int num_xforms, int this_x
void flam3_interpolate_n(flam3_genome *result, int ncp,
flam3_genome *cpi, double *c, double stagger) {
int i, j, k, numstd;
if (flam3_palette_interpolation_hsv == cpi[0].palette_interpolation) {
fprintf(stderr, "xxx pi=%d\n", cpi[0].palette_interpolation);
if (flam3_palette_interpolation_sweep != cpi[0].palette_interpolation) {
for (i = 0; i < 256; i++) {
double t[3], s[5];
int alpha1 = 1;
s[0] = s[1] = s[2] = s[3] = s[4] = 0.0;
for (k = 0; k < ncp; k++) {
rgb2hsv(cpi[k].palette[i].color, t);
if (i == 0) {
fprintf(stderr, "ncp=%d, k=%d\n", ncp, k);
fprintf(stderr, "rgb=%g %g %g\n", cpi[k].palette[i].color[0], cpi[k].palette[i].color[1], cpi[k].palette[i].color[2]);
}
if (flam3_palette_interpolation_rgb != cpi[0].palette_interpolation)
rgb2hsv(cpi[k].palette[i].color, t);
else {
int l;
for (l = 0; l < 3; l++)
t[l] = cpi[k].palette[i].color[l];
}
if (i == 0) {
fprintf(stderr, "hsv=%g %g %g\n", t[0], t[1], t[2]);
}
if (2 == ncp && cpi[0].palette_interpolation == flam3_palette_interpolation_hsv2) {
/* should also support blending between rgb and hsv,
and change the color of the cut, so we can keep
a dominant color but control what it is. */
double z[3];
rgb2hsv(cpi[1-k].palette[i].color, z);
if ((z[0] - t[0]) > 3.0) t[0] += 6.0;
if (i == 0)
fprintf(stderr, "adjusted %g %g\n", z[0], t[0]);
}
for (j = 0; j < 3; j++)
s[j] += c[k] * t[j];
@ -385,10 +421,25 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
if (alpha1 == 1)
s[3] = 1.0;
if (i == 0)
fprintf(stderr, "s0=%g\n", s[0]);
hsv2rgb(s, result->palette[i].color);
if (flam3_palette_interpolation_rgb != cpi[0].palette_interpolation)
hsv2rgb(s, result->palette[i].color);
else {
int l;
for (l = 0; l < 3; l++)
result->palette[i].color[l] = s[l];
}
result->palette[i].color[3] = s[3];
result->palette[i].index = s[4];
if (i == 0)
fprintf(stderr, "result rgb=%g %g %g\n",
result->palette[0].color[0],
result->palette[0].color[1],
result->palette[0].color[2]);
for (j = 0; j < 4; j++) {
if (result->palette[i].color[j] < 0.0)
@ -417,6 +468,7 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
result->palette_mode = cpi[0].palette_mode;
result->interpolation_type = cpi[0].interpolation_type;
result->palette_interpolation = cpi[0].palette_interpolation;
INTERP(brightness);
INTERP(contrast);
INTERP(highlight_power);

View File

@ -2,7 +2,7 @@
# libtool - Provide generalized library-building support services.
# Generated automatically by config.status (flam3) 3.0
# Libtool was configured on host flame64:
# Libtool was configured on host li263-19:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
@ -234,10 +234,10 @@ finish_eval=""
hardcode_into_libs=yes
# Compile-time system search path for libraries.
sys_lib_search_path_spec="/usr/lib/gcc/i486-linux-gnu/4.4.3 /usr/lib /lib /usr/lib/i486-linux-gnu"
sys_lib_search_path_spec="/usr/lib/gcc/i686-linux-gnu/4.6 /usr/lib/i386-linux-gnu /usr/lib /lib/i386-linux-gnu /lib"
# Run-time system search path for libraries.
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/nvidia-current /lib/i486-linux-gnu /usr/lib/i486-linux-gnu /usr/lib/alsa-lib /usr/local/lib "
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/i386-linux-gnu/mesa /lib/i386-linux-gnu /usr/lib/i386-linux-gnu /lib/i686-linux-gnu /usr/lib/i686-linux-gnu /usr/local/lib "
# Whether dlopen is supported.
dlopen_support=unknown

View File

@ -341,6 +341,10 @@ int parse_flame_element(xmlNode *flame_node, flam3_genome *loc_current_cp) {
cp->palette_interpolation = flam3_palette_interpolation_hsv;
} else if (!strcmp("sweep", att_str)) {
cp->palette_interpolation = flam3_palette_interpolation_sweep;
} else if (!strcmp("hsv2", att_str)) {
cp->palette_interpolation = flam3_palette_interpolation_hsv2;
} else if (!strcmp("rgb", att_str)) {
cp->palette_interpolation = flam3_palette_interpolation_rgb;
} else {
fprintf(stderr, "warning: unrecognized palette interpolation type %s.\n", att_str);
}