Skip to content

Commit

Permalink
Coloring shift
Browse files Browse the repository at this point in the history
  • Loading branch information
PC-SUMMO\Michele Summo committed Feb 11, 2022
1 parent c663880 commit 146ca76
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/engine/formulas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static void color_f_normalize(number_t &v) {
}
}

static float color_f_func(number_t v, const float speed, const int func) {
static float color_f_func(number_t v, const float speed, const int func, const int shift) {
color_f_normalize(v);
switch (func) {
case 1:
Expand Down Expand Up @@ -235,23 +235,26 @@ static float color_f_func(number_t v, const float speed, const int func) {
break;
}
v = v * speed;
v += shift;
color_f_normalize(v);
return v;
}

static void color_precalc(number_t &iter, int inset) {
const float speed = inset ? cfractalc.incolorspeed : cfractalc.outcolorspeed;
const int func = inset ? cfractalc.incolorfun : cfractalc.outcolorfun;
iter = (color_f_func(iter / SMUL, speed, func) * SMUL);
const int shift = inset ? cfractalc.incolorshift : cfractalc.outcolorshift;
iter = (color_f_func(iter / SMUL, speed, func, shift) * SMUL);
}
static void color_precalc(number_t &zre, number_t &zim, number_t &pre,
number_t &pim, int inset) {
const float speed = inset ? cfractalc.incolorspeed : cfractalc.outcolorspeed;
const int func = inset ? cfractalc.incolorfun : cfractalc.outcolorfun;
zre = color_f_func(zre, speed, func);
zim = color_f_func(zim, speed, func);
pre = color_f_func(pre, speed, func);
pim = color_f_func(pim, speed, func);
const int shift = inset ? cfractalc.incolorshift : cfractalc.outcolorshift;
zre = color_f_func(zre, speed, func, shift);
zim = color_f_func(zim, speed, func, shift);
pre = color_f_func(pre, speed, func, shift);
pim = color_f_func(pim, speed, func, shift);
}

/* 2009-07-30 JB Langston:
Expand Down
2 changes: 2 additions & 0 deletions src/engine/fractal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,10 @@ fractal_context *make_fractalc(const int formula, float wi, float he)
new_ctxt->outtcolor = 0;
new_ctxt->incolorfun = 0;
new_ctxt->incolorspeed = 1.0f;
new_ctxt->incolorshift = 0;
new_ctxt->outcolorfun = 0;
new_ctxt->outcolorspeed = 1.0f;
new_ctxt->outcolorshift = 0;
new_ctxt->slowmode = 0;
new_ctxt->range = 3;
new_ctxt->angle = 0;
Expand Down
1 change: 1 addition & 0 deletions src/include/fractal.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct fractal_context {
//MSUMMO BEGIN HACK
number_t incolorspeed, outcolorspeed;
int incolorfun, outcolorfun;
int incolorshift, outcolorshift;
//MSUMMO END HACK
int mandelbrot;
int plane;
Expand Down
2 changes: 2 additions & 0 deletions src/include/ui_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,10 @@ void uih_setouttcolor(uih_context *c, int mode);

void uih_setincolorspeed(uih_context *c, number_t speed);
void uih_setincolorfun(uih_context *c, int func);
void uih_setincolorshift(uih_context *c, int shift);
void uih_setoutcolorspeed(uih_context *c, number_t speed);
void uih_setoutcolorfun(uih_context *c, int func);
void uih_setoutcolorshift(uih_context *c, int shift);

void uih_setplane(uih_context *c, int mode);
void uih_setmandelbrot(uih_context *c, int mode, int mousex, int mousey);
Expand Down
27 changes: 27 additions & 0 deletions src/ui-hlp/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,21 @@ static menudialog *uih_getoutcolorspeeddialog(struct uih_context *c)
return (uih_fpdialog);
}

static menudialog *uih_getincolorshiftdialog(struct uih_context *c)
{
if (c != NULL)
uih_numdialog[0].defint = c->fcontext->incolorshift;
return (uih_numdialog);
}

static menudialog *uih_getoutcolorshiftdialog(struct uih_context *c)
{
if (c != NULL)
uih_numdialog[0].defint = c->fcontext->outcolorshift;
return (uih_numdialog);
}


int defthreads = 0;

static menudialog *uih_getthreaddialog(struct uih_context *c)
Expand Down Expand Up @@ -1333,6 +1348,12 @@ void uih_registermenus_i18n(void)
MENUDIALOG_I("fractal", NULL, TR("Menu", "Outside coloring speed"),
"outcolorspeed", MENUFLAG_NOMENU | MENUFLAG_INTERRUPT,
uih_setoutcolorspeed, uih_fpdialog);
MENUDIALOG_I("fractal", NULL, TR("Menu", "Inside coloring shift"),
"incolorshift", MENUFLAG_NOMENU | MENUFLAG_INTERRUPT,
uih_setincolorshift, uih_numdialog);
MENUDIALOG_I("fractal", NULL, TR("Menu", "Outside coloring shift"),
"outcolorshift", MENUFLAG_NOMENU | MENUFLAG_INTERRUPT,
uih_setoutcolorshift, uih_numdialog);
MENUDIALOG_I("fractal", NULL, TR("Menu", "Julia seed"), "juliaseed",
MENUFLAG_NOMENU | MENUFLAG_INTERRUPT, uih_setjuliaseed,
uih_coorddialog);
Expand Down Expand Up @@ -1517,6 +1538,12 @@ static const menuitem menuitems2[] = {
MENUCDIALOG("moutcoloring", NULL, TR("Menu", "Coloring speed"), "moutcolorspeed",
MENUFLAG_INTERRUPT,
uih_setoutcolorspeed, uih_getoutcolorspeeddialog),
MENUCDIALOG("mincoloring", NULL, TR("Menu", "Coloring shift"), "mincolorshift",
MENUFLAG_INTERRUPT,
uih_setincolorshift, uih_getincolorshiftdialog),
MENUCDIALOG("moutcoloring", NULL, TR("Menu", "Coloring shift"), "moutcolorshift",
MENUFLAG_INTERRUPT,
uih_setoutcolorshift, uih_getoutcolorshiftdialog),
SUBMENU("mincoloring", NULL, "Coloring speed functions",
"mincolorfun"),
SUBMENU("moutcoloring", NULL, "Coloring speed functions",
Expand Down
8 changes: 8 additions & 0 deletions src/ui-hlp/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,18 @@ void uih_saveframe(struct uih_context *uih)
if (s->fcontext->incolorspeed != uih->fcontext->incolorspeed)
save_floatc(uih, "incolorspeed", uih->fcontext->incolorspeed),
s->fcontext->incolorspeed = uih->fcontext->incolorspeed;
if (s->fcontext->incolorshift != uih->fcontext->incolorshift)
save_intc(uih, "incolorshift", uih->fcontext->incolorshift),
s->fcontext->incolorshift = uih->fcontext->incolorshift;
if (s->fcontext->outcolorfun != uih->fcontext->outcolorfun)
save_intc(uih, "outcolorfun", uih->fcontext->outcolorfun),
s->fcontext->outcolorfun = uih->fcontext->outcolorfun;
if (s->fcontext->outcolorspeed != uih->fcontext->outcolorspeed)
save_floatc(uih, "outcolorspeed", uih->fcontext->outcolorspeed),
s->fcontext->outcolorspeed = uih->fcontext->outcolorspeed;
if (s->fcontext->outcolorshift != uih->fcontext->outcolorshift)
save_intc(uih, "outcolorshift", uih->fcontext->outcolorshift),
s->fcontext->outcolorshift = uih->fcontext->outcolorshift;
if (s->fcontext->mandelbrot != uih->fcontext->mandelbrot)
save_onoffc(uih, "julia", !uih->fcontext->mandelbrot),
s->fcontext->mandelbrot = uih->fcontext->mandelbrot;
Expand Down Expand Up @@ -608,8 +614,10 @@ int uih_save_enable(struct uih_context *uih, xio_file f, int mode)
s->fcontext->mandelbrot = 1;
s->fcontext->incolorfun = 0;
s->fcontext->incolorspeed = 1.0f;
s->fcontext->incolorshift = 0;
s->fcontext->outcolorfun = 0;
s->fcontext->outcolorspeed = 1.0f;
s->fcontext->outcolorshift = 0;
s->fcontext->plane = 0;
s->fcontext->range = 3;
s->fcontext->angle = 0;
Expand Down
18 changes: 18 additions & 0 deletions src/ui-hlp/ui_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,14 @@ void uih_setincolorfun(uih_context *c, int func){
}
}

void uih_setincolorshift(uih_context *c, int shift) {
if (c->fcontext->incolorshift != shift) {
c->fcontext->incolorshift = shift;
c->fcontext->version++;
uih_newimage(c);
}
}

void uih_setoutcolorspeed(uih_context *c, number_t speed){
if (c->fcontext->outcolorspeed != (number_t)speed) {
c->fcontext->outcolorspeed = speed;
Expand All @@ -1812,6 +1820,14 @@ void uih_setoutcolorfun(uih_context *c, int func){
}
}

void uih_setoutcolorshift(uih_context *c, int shift) {
if (c->fcontext->outcolorshift != shift) {
c->fcontext->outcolorshift = shift;
c->fcontext->version++;
uih_newimage(c);
}
}

void uih_setperbutation(uih_context *c, number_t zre, number_t zim)
{
if (c->fcontext->bre != zre || c->fcontext->bim != zim) {
Expand Down Expand Up @@ -2178,8 +2194,10 @@ void uih_initstate(struct uih_context *uih)
uih_setoutcoloringmode(uih, 0);
uih_setincolorspeed(uih, 1.0);
uih_setincolorfun(uih, 0);
uih_setincolorshift(uih, 0);
uih_setoutcolorspeed(uih, 1.0);
uih_setoutcolorfun(uih, 0);
uih_setoutcolorshift(uih, 0);
uih_setcycling(uih, 30);
uih_display(uih);
uih_setfastmode(uih, 2);
Expand Down

0 comments on commit 146ca76

Please sign in to comment.