still need to change interp mode to hsv_circular

This commit is contained in:
EReckase 2015-04-11 17:44:36 -06:00
parent a1065bee5c
commit d8fbddac62
2 changed files with 34 additions and 26 deletions

View File

@ -480,7 +480,7 @@ 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[0], blend*360.0, spun[0].interpolation_type);
flam3_rotate(&spun[1], 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); //fprintf(stderr, "xyzzy %d %d\n", spun[0].palette_interpolation, spun[1].palette_interpolation);
/* Now call the interpolation */ /* Now call the interpolation */
if (argi("unsmoother",0) == 0) if (argi("unsmoother",0) == 0)

View File

@ -172,13 +172,15 @@ void interpolate_cmap(flam3_palette cmap, double blend,
t[4] = p1[i].index; t[4] = p1[i].index;
/* take the shorter way around the hue circle */ /* take the shorter way around the hue circle */
if (0 == i) { // if (0 == i) {
fprintf(stderr, "xxx interpolating between hues, %g %g\n", s[0], t[0]); // fprintf(stderr, "xxx interpolating between hues, %g %g\n", s[0], t[0]);
} // }
if ((s[0] - t[0]) > 3.0)
/* Correct the first hue to go the short way around */
if ((s[0] - t[0]) > 3.0) /* first hue much bigger than second hue */
s[0] -= 6.0
if ((s[0] - t[0]) < -3.0) /* first hue much smaller than second hue */
s[0] += 6.0; s[0] += 6.0;
if ((t[0] - s[0]) > 3.0)
t[0] += 6.0;
for (j = 0; j < 5; j++) for (j = 0; j < 5; j++)
t[j] = ((1.0-blend) * s[j]) + (blend * t[j]); t[j] = ((1.0-blend) * s[j]) + (blend * t[j]);
@ -372,7 +374,7 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
flam3_genome *cpi, double *c, double stagger) { flam3_genome *cpi, double *c, double stagger) {
int i, j, k, numstd; int i, j, k, numstd;
fprintf(stderr, "xxx pi=%d\n", cpi[0].palette_interpolation); // fprintf(stderr, "xxx pi=%d\n", cpi[0].palette_interpolation);
if (flam3_palette_interpolation_sweep != cpi[0].palette_interpolation) { if (flam3_palette_interpolation_sweep != cpi[0].palette_interpolation) {
@ -384,8 +386,8 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
for (k = 0; k < ncp; k++) { for (k = 0; k < ncp; k++) {
if (i == 0) { if (i == 0) {
fprintf(stderr, "ncp=%d, k=%d\n", ncp, k); // 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]); // 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) if (flam3_palette_interpolation_rgb != cpi[0].palette_interpolation)
rgb2hsv(cpi[k].palette[i].color, t); rgb2hsv(cpi[k].palette[i].color, t);
@ -394,19 +396,25 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
for (l = 0; l < 3; l++) for (l = 0; l < 3; l++)
t[l] = cpi[k].palette[i].color[l]; t[l] = cpi[k].palette[i].color[l];
} }
if (i == 0) { // if (i == 0) {
fprintf(stderr, "hsv=%g %g %g\n", t[0], t[1], t[2]); // fprintf(stderr, "hsv=%g %g %g\n", t[0], t[1], t[2]);
} // }
if (2 == ncp && cpi[0].palette_interpolation == flam3_palette_interpolation_hsv2) { if (2 == ncp && k == 0 &&cpi[0].palette_interpolation == flam3_palette_interpolation_hsv2) {
/* should also support blending between rgb and hsv, /* should also support blending between rgb and hsv,
and change the color of the cut, so we can keep and change the color of the cut, so we can keep
a dominant color but control what it is. */ a dominant color but control what it is. */
double z[3];
rgb2hsv(cpi[1-k].palette[i].color, z); /* only adjust the first coordinate based on the other control point's hue */
if ((z[0] - t[0]) > 3.0) t[0] += 6.0; double second_color[3];
if (i == 0) rgb2hsv(cpi[1].palette[i].color, second_color);
fprintf(stderr, "adjusted %g %g\n", z[0], t[0]);
/* Adjust the hue so that we go the shorter direction around the circle */
if ((second_color[0] - t[0]) > 3.0) {
t[0] += 6.0;
} else if ((second_color[0] - t[0]) < -3.0) {
t[0] -= 6.0;
}
} }
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
@ -422,8 +430,8 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
if (alpha1 == 1) if (alpha1 == 1)
s[3] = 1.0; s[3] = 1.0;
if (i == 0) // if (i == 0)
fprintf(stderr, "s0=%g\n", s[0]); // fprintf(stderr, "s0=%g\n", s[0]);
if (flam3_palette_interpolation_rgb != cpi[0].palette_interpolation) if (flam3_palette_interpolation_rgb != cpi[0].palette_interpolation)
hsv2rgb(s, result->palette[i].color); hsv2rgb(s, result->palette[i].color);
@ -435,11 +443,11 @@ void flam3_interpolate_n(flam3_genome *result, int ncp,
result->palette[i].color[3] = s[3]; result->palette[i].color[3] = s[3];
result->palette[i].index = s[4]; result->palette[i].index = s[4];
if (i == 0) // if (i == 0)
fprintf(stderr, "result rgb=%g %g %g\n", // fprintf(stderr, "result rgb=%g %g %g\n",
result->palette[0].color[0], // result->palette[0].color[0],
result->palette[0].color[1], // result->palette[0].color[1],
result->palette[0].color[2]); // result->palette[0].color[2]);
for (j = 0; j < 4; j++) { for (j = 0; j < 4; j++) {
if (result->palette[i].color[j] < 0.0) if (result->palette[i].color[j] < 0.0)