diff --git a/XaoS.pro b/XaoS.pro index 69f0fb54..7704c641 100644 --- a/XaoS.pro +++ b/XaoS.pro @@ -7,6 +7,8 @@ wasm { lessThan(QT_MINOR_VERSION, 5): error("requires Qt >= 6.5.2") } +QMAKE_CXXFLAGS += -Wall -Wextra -Wpedantic + TEMPLATE = app QT += widgets diff --git a/catalogs/de.cat b/catalogs/de.cat index 0b28266e..d675ca46 100644 --- a/catalogs/de.cat +++ b/catalogs/de.cat @@ -786,6 +786,35 @@ Hi-Color- oder Real-Color-Modus. Bei 8bpp-Darstellung muss dazu der Truecolor-Filter eingeschaltet werden." +smoothlog "Farbverlauf logarithmisch + +Der logarithmische Farbverlauf ist grundsätzlich +gleich wie der normale Farbverlauf, es wird einfach +der Logarithmus der interpolierten Iterationen +zur Bestimmung des Farbwertes verwendet. + +Dadurch wird das Bild in chaotischen +Bereichen viel ruhiger." + +smoothlog0 "Es werden mehr Details sichtbar +und die Bilder wirken filigraner." + +smoothlog1 "Dabei gelten dieselben Einschränkungen wie beim +normalen Farbverlauf (Funktioniert nicht bei \"Newton\" und \"Magnet\" +und benötigt Truecolor)." + +smoothlog2 "Als Beispiel dreimal derselbe Ausschnitt, einmal +ohne Farbverlauf, einmal mit normalem Farbverlauf und anschliessend +mit logarithmischem Farbverlauf." + +smoothlog_nosmooth "Ohne Farbverlauf." + +smoothlog_smooth "Mit normalem Farbverlauf." + + +smoothlog_smoothlog "Mit logarithmischem Farbverlauf." + + ######################################################### # Datei: outnew.xhf diff --git a/catalogs/en.cat b/catalogs/en.cat index 2045ffdb..87b8f8b5 100644 --- a/catalogs/en.cat +++ b/catalogs/en.cat @@ -792,6 +792,30 @@ high color display modes. So if you have 8bpp, you will need to enable the true color filter." +smoothlog "smooth log + +Smooth log is basically the same as smooth, +but takes the logarithm of the interpolated +itervalue, so the coloring gets much +quieter in chaotic places." + +smoothlog0 " Thus more +details are visible. +Also the images look finer" + +smoothlog1 "It has the same restrictions as +smooth (No Newton, no magnet and only works for true color." + +smoothlog2 "For example the same image without using smooth, +with smooth and with smooth log." + +smoothlog_nosmooth "without using smooth." + +smoothlog_smooth "just using smooth." + + +smoothlog_smoothlog "The same image using smooth log." + ######################################################### #For file outnew.xhf diff --git a/src/engine/formulas.cpp b/src/engine/formulas.cpp index 14850fce..1e735721 100644 --- a/src/engine/formulas.cpp +++ b/src/engine/formulas.cpp @@ -77,6 +77,7 @@ const char *const outcolorname[] = {"iter", "potential", "color decomposition", "smooth", + "smooth log", "True-color", NULL}; @@ -114,7 +115,7 @@ const char *const tcolorname[] = { #define OUTOUTPUT() \ STAT(niter2 += iter); \ - return (!cfractalc.coloringmode \ + return (cfractalc.coloringmode == OutColormodeType::ColOut_iter \ ? cpalette.pixels[(iter % (cpalette.size - 1)) + 1] \ : color_output(zre, zim, iter)) #define INOUTPUT() \ @@ -130,7 +131,7 @@ const char *const tcolorname[] = { truecolor_output(zre, zim, pre, pim, cfractalc.intcolor, 1)); \ INOUTPUT(); \ } else { \ - if (cfractalc.coloringmode == 10) \ + if (cfractalc.coloringmode == OutColormodeClass::ColOut_True_color) \ return ( \ truecolor_output(zre, zim, pre, pim, cfractalc.outtcolor, 0)); \ OUTOUTPUT(); \ @@ -144,6 +145,9 @@ const char *const tcolorname[] = { iter = (int)(((cfractalc.maxiter - iter) * 256 + \ log((double)(cfractalc.bailout / (szmag))) / \ log((double)((zre) / (szmag))) * 256)); \ + if (cfractalc.coloringmode == OutColormodeClass::ColOut_smooth_log) { \ + iter = log(iter) * ((cpalette.size - 1))/log(cfractalc.maxiter * 256) + 1; \ + }\ iter %= ((unsigned int)(cpalette.size - 1)) << 8; \ \ if ((cpalette.type & (C256 | SMALLITER)) || !(iter & 255)) \ @@ -410,35 +414,36 @@ static unsigned int color_output(number_t zre, number_t zim, unsigned int iter) iter <<= SHIFT; i = iter; - switch (cfractalc.coloringmode) { - case 9: + switch (cfractalc.coloringmode.ColorMode) { + case OutColormodeType::ColOut_smooth: + case OutColormodeType::ColOut_smooth_log: break; - case 1: /* real */ + case OutColormodeType::ColOut_iter_plus_real: /* real */ i = (int)(iter + zre * SMUL); break; - case 2: /* imag */ + case OutColormodeType::ColOut_iter_plus_imag: /* imag */ i = (int)(iter + zim * SMUL); break; - case 3: /* real / imag */ + case OutColormodeType::ColOut_iter_plus_real_div_imag: /* real / imag */ i = (int)(iter + (zre / zim) * SMUL); break; - case 4: /* all of the above */ + case OutColormodeType::ColOut_iter_plus_real_plus_imag_plus_real_div_imag: /* all of the above */ i = (int)(iter + (zre + zim + zre / zim) * SMUL); break; - case 5: + case OutColormodeType::ColOut_binary_decomposition: if (zim > 0) i = ((cfractalc.maxiter << SHIFT) - iter); break; - case 6: + case OutColormodeType::ColOut_biomorphs: if (myabs(zim) < 2.0 || myabs(zre) < 2.0) i = ((cfractalc.maxiter << SHIFT) - iter); break; - case 7: + case OutColormodeType::ColOut_potential: zre = zre * zre + zim * zim; i = (int)(sqrt(log((double)zre) / i) * 256 * 256); break; default: - case 8: + case OutColormodeType::ColOut_color_decomposition: i = (int)((atan2((double)zre, (double)zim) / (M_PI + M_PI) + 0.75) * 20000); break; @@ -1437,6 +1442,7 @@ const struct formula formulas[] = { {INT_MAX, 0, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, 0, 0, NULL}, + {INT_MAX, 0, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1477,6 +1483,7 @@ const struct formula formulas[] = { {0, 0, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {0, 0, 0, NULL}, + {0, 0, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1517,6 +1524,7 @@ const struct formula formulas[] = { {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, 0, 2, sym6}, + {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1557,6 +1565,7 @@ const struct formula formulas[] = { {0, 0, 2, sym8}, {INT_MAX, INT_MAX, 0, NULL}, {0, 0, 2, sym8}, + {0, 0, 2, sym8}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1597,6 +1606,7 @@ const struct formula formulas[] = { {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, 0, 2, sym6}, + {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1637,6 +1647,7 @@ const struct formula formulas[] = { {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, 0, 2, sym6}, + {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -1677,6 +1688,7 @@ const struct formula formulas[] = { {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, 0, 2, sym6}, + {INT_MAX, 0, 2, sym6}, {INT_MAX, INT_MAX, 0, NULL}, }, { @@ -2429,6 +2441,7 @@ const struct formula formulas[] = { {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, + {INT_MAX, INT_MAX, 0, NULL}, }, { {INT_MAX, INT_MAX, 0, NULL}, @@ -2468,6 +2481,7 @@ const struct formula formulas[] = { {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, + {INT_MAX, INT_MAX, 0, NULL}, }, { {INT_MAX, INT_MAX, 0, NULL}, @@ -2507,6 +2521,7 @@ const struct formula formulas[] = { {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, + {INT_MAX, INT_MAX, 0, NULL}, }, { {INT_MAX, INT_MAX, 0, NULL}, @@ -2587,6 +2602,7 @@ const struct formula formulas[] = { {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, + {INT_MAX, INT_MAX, 0, NULL}, }, { {INT_MAX, INT_MAX, 0, NULL}, @@ -2637,6 +2653,7 @@ const struct formula formulas[] = { {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, {INT_MAX, INT_MAX, 0, NULL}, + {INT_MAX, INT_MAX, 0, NULL}, }, { {INT_MAX, INT_MAX, 0, NULL}, diff --git a/src/engine/fractal.cpp b/src/engine/fractal.cpp index d1681797..5e0b3112 100644 --- a/src/engine/fractal.cpp +++ b/src/engine/fractal.cpp @@ -87,7 +87,7 @@ combine_methods(void) { int angle = (int)cfractalc.angle; const struct symmetryinfo *s1 = cfractalc.currentformula->out + - cfractalc.coloringmode, + cfractalc.coloringmode.AsInt(), *s2 = cfractalc.currentformula->in + cfractalc.incoloringmode; if (angle < 0) { @@ -229,7 +229,7 @@ void set_fractalc(fractal_context *context, struct image *img) if (cursymmetry.ysym == (number_t)INT_MAX) cursymmetry.ysym = cfractalc.rs.mi + INT_MAX; - if (cfractalc.coloringmode == 9 && cformula.smooth_calculate != NULL && + if ((cfractalc.coloringmode == OutColormodeType::ColOut_smooth || cfractalc.coloringmode == OutColormodeType::ColOut_smooth_log) && cformula.smooth_calculate != NULL && (cpalette.type & (TRUECOLOR | TRUECOLOR16 | TRUECOLOR24 | GRAYSCALE | LARGEITER))) { cfractalc.calculate[0] = cformula.smooth_calculate; @@ -307,7 +307,7 @@ fractal_context *make_fractalc(const int formula, float wi, float he) new_ctxt->windowheight = he; new_ctxt->maxiter = DEFAULT_MAX_ITER; new_ctxt->bailout = DEFAULT_BAILOUT; - new_ctxt->coloringmode = 0; + new_ctxt->coloringmode = OutColormodeType::ColOut_iter; new_ctxt->intcolor = 0; new_ctxt->outtcolor = 0; new_ctxt->slowmode = 0; diff --git a/src/include/fractal.h b/src/include/fractal.h index 2d3054ae..27ac83d1 100644 --- a/src/include/fractal.h +++ b/src/include/fractal.h @@ -28,9 +28,37 @@ #endif #define INCOLORING 11 -#define OUTCOLORING 11 +#define OUTCOLORING (OutColormodeClass::ColOut_MAXMode + 1) #define TCOLOR 15 +class OutColormodeClass { +public: +enum OutColormode { + ColOut_iter, + ColOut_iter_plus_real, + ColOut_iter_plus_imag, + ColOut_iter_plus_real_div_imag, + ColOut_iter_plus_real_plus_imag_plus_real_div_imag, + ColOut_binary_decomposition, + ColOut_biomorphs, + ColOut_potential, + ColOut_color_decomposition, + ColOut_smooth, + ColOut_smooth_log, + ColOut_True_color, + ColOut_MAXMode = ColOut_True_color + }; + enum OutColormode ColorMode; + int AsInt() {return ColorMode; } + OutColormodeClass &operator=(enum OutColormode Color) {ColorMode = Color; return *this;} + + bool operator==(enum OutColormode Color) {return ColorMode == Color;} + bool operator!=(enum OutColormode Color) {return ColorMode != Color;} + bool operator!=(const OutColormodeClass &Color) {return ColorMode == Color.ColorMode;} +}; + +typedef OutColormodeClass OutColormodeType; + typedef struct { number_t y0, k; } symmetrytype; @@ -65,6 +93,8 @@ struct formula { int flags; }; + + struct fractal_context { number_t pre, pim; number_t bre, bim; @@ -77,7 +107,8 @@ struct fractal_context { int periodicity; unsigned int maxiter; number_t bailout; - int coloringmode, incoloringmode; + OutColormodeType coloringmode; + int incoloringmode; int intcolor, outtcolor; int mandelbrot; int plane; @@ -113,7 +144,7 @@ struct symmetryinfo2 { #define BTRACEOK \ ((cformula.flags & (2 << cfractalc.mandelbrot)) && \ - !cfractalc.incoloringmode && cfractalc.coloringmode != 7) + !cfractalc.incoloringmode && cfractalc.coloringmode != OutColormodeType::ColOut_potential) #define my_rotate(f, x, y) \ { \ number_t tmp; \ diff --git a/src/ui-hlp/menu.cpp b/src/ui-hlp/menu.cpp index c6a25319..73fe6407 100644 --- a/src/ui-hlp/menu.cpp +++ b/src/ui-hlp/menu.cpp @@ -11,6 +11,7 @@ #include "filter.h" #include "config.h" #include "formulas.h" +#include "fractal.h" // For OutColormodeType osi1 20220213 #include "ui_helper.h" #include "plane.h" #include "xmenu.h" @@ -1524,7 +1525,7 @@ static int uih_selectedoutcoloring(struct uih_context *c, int n) { if (c == NULL) return 0; - return (c->fcontext->coloringmode == n); + return (c->fcontext->coloringmode.AsInt() == n); } static int uih_selectedplane(struct uih_context *c, int n) @@ -1536,7 +1537,7 @@ static int uih_selectedplane(struct uih_context *c, int n) static void uih_setouttruecolor(struct uih_context *c, int n) { - uih_setoutcoloringmode(c, 10); + uih_setoutcoloringmode(c, OutColormodeType::ColOut_True_color); uih_setouttcolor(c, n); } diff --git a/src/ui-hlp/save.cpp b/src/ui-hlp/save.cpp index 6bbcdf99..23d59f7e 100644 --- a/src/ui-hlp/save.cpp +++ b/src/ui-hlp/save.cpp @@ -456,7 +456,7 @@ void uih_saveframe(struct uih_context *uih) save_floatc(uih, "bailout", uih->fcontext->bailout), s->fcontext->bailout = uih->fcontext->bailout; if (s->fcontext->coloringmode != uih->fcontext->coloringmode) - save_intc(uih, "outcoloring", uih->fcontext->coloringmode), + save_intc(uih, "outcoloring", uih->fcontext->coloringmode.AsInt()), s->fcontext->coloringmode = uih->fcontext->coloringmode; if (s->fcontext->incoloringmode != uih->fcontext->incoloringmode) save_intc(uih, "incoloring", uih->fcontext->incoloringmode), @@ -468,7 +468,7 @@ void uih_saveframe(struct uih_context *uih) s->fcontext->intcolor != uih->fcontext->intcolor) save_intc(uih, "intcoloring", uih->fcontext->intcolor), s->fcontext->intcolor = uih->fcontext->intcolor; - if ((s->fcontext->coloringmode == 10 || s->mode >= UIH_SAVEALL) && + if ((s->fcontext->coloringmode == OutColormodeType::ColOut_True_color || s->mode >= UIH_SAVEALL) && s->fcontext->outtcolor != uih->fcontext->outtcolor) save_intc(uih, "outtcoloring", uih->fcontext->outtcolor), s->fcontext->outtcolor = uih->fcontext->outtcolor; @@ -589,7 +589,7 @@ int uih_save_enable(struct uih_context *uih, xio_file f, int mode) s->fcontext->periodicity = 1; s->fcontext->maxiter = 170; s->fcontext->bailout = 4; - s->fcontext->coloringmode = 0; + s->fcontext->coloringmode = OutColormodeType::ColOut_iter; s->fcontext->incoloringmode = 0; s->fcontext->outtcolor = 0; s->fcontext->intcolor = 0; diff --git a/src/ui-hlp/ui_helper.cpp b/src/ui-hlp/ui_helper.cpp index d07854df..f6316144 100644 --- a/src/ui-hlp/ui_helper.cpp +++ b/src/ui-hlp/ui_helper.cpp @@ -1789,7 +1789,7 @@ void uih_setouttcolor(uih_context *c, int mode) if (c->fcontext->outtcolor != mode) { char str[10]; c->fcontext->outtcolor = mode; - if (c->fcontext->coloringmode == 10) { + if (c->fcontext->coloringmode == OutColormodeType::ColOut_True_color) { c->fcontext->version++; uih_newimage(c); } @@ -1849,13 +1849,15 @@ void uih_setfastmode(uih_context *c, int mode) void uih_setoutcoloringmode(uih_context *c, int mode) { + // Not sure where negative values might come from + // so stayed in the int space and not converted to enum if (mode < 0) mode = rand() % OUTCOLORING; if (mode > OUTCOLORING) mode = OUTCOLORING - 1; - if (c->fcontext->coloringmode != mode) { + if (c->fcontext->coloringmode != (OutColormodeType::OutColormode)mode) { char str[10]; - c->fcontext->coloringmode = mode; + c->fcontext->coloringmode = (OutColormodeType::OutColormode)mode; c->fcontext->version++; uih_newimage(c); sprintf(str, "out%i", mode); @@ -2316,7 +2318,7 @@ void uih_updatestatus(uih_context *uih) "%s %.2f times (%.1fE) %2.2f frames/sec %c %i %i %i %u "), times < 1 ? TR("Message", "unzoomed") : TR("Message", "zoomed"), times < 1 ? 1.0 / times : times, timesnop, speed, - uih->autopilot ? 'A' : ' ', uih->fcontext->coloringmode + 1, + uih->autopilot ? 'A' : ' ', uih->fcontext->coloringmode.AsInt() + 1, uih->fcontext->incoloringmode + 1, uih->fcontext->plane + 1, uih->fcontext->maxiter); @@ -2398,7 +2400,7 @@ static void uih_drawstatus(uih_context *uih, void * /*data*/) BGCOLOR(uih), 0); sprintf(str, TR("Message", "incoloring:%s outcoloring:%s"), incolorname[uih->fcontext->incoloringmode], - outcolorname[uih->fcontext->coloringmode]); + outcolorname[uih->fcontext->coloringmode.AsInt()]); xprint(uih->image, uih->font, 0, statusstart + 8 * h, str, FGCOLOR(uih), BGCOLOR(uih), 0); sprintf(str, TR("Message", "zoomspeed:%f"), (float)uih->maxstep * 1000); diff --git a/src/ui/customdialog.cpp b/src/ui/customdialog.cpp index 1f3513bf..a8984d65 100644 --- a/src/ui/customdialog.cpp +++ b/src/ui/customdialog.cpp @@ -135,7 +135,7 @@ CustomDialog::CustomDialog(struct uih_context *uih, const menuitem *item, algono = new QSpinBox(this); algono->setObjectName(label + "algono"); algono->setValue(palcontext->palettetype); - algono->setRange(1, 3); + algono->setRange(1, PALGORITHMS); // Algo Slider algoslider = new QSlider(Qt::Horizontal, this); diff --git a/tutorial/outnew.xhf b/tutorial/outnew.xhf index bcb2a95c..dc8c5caf 100644 --- a/tutorial/outnew.xhf +++ b/tutorial/outnew.xhf @@ -206,3 +206,49 @@ (view -0.65025 -0.050542 0.18216 0.18216) (usleep 2000000) (filter 'truecolor #f) + +; SMOOTH LOG +(usleep 2000000) +(clearscreen) +(filter 'truecolor #t) +(textposition 'center 'middle) +(message "smoothlog") +(textsleep) +(clearscreen) +(message "smoothlog0") +(textsleep) +(clearscreen) +(message "smoothlog1") +(textsleep) +(clearscreen) +(message "smoothlog2") +(textsleep) + +(outcoloring 0) +(formula 'mandel) +(maxiter 100000) +(palette 3 598488124 0) +(maxiter 100000) +(view -0.7796352399 -0.1349988879 4.549645328E-06 4.54964533E-06) +;(view -1.255597 -0.028686236 0.00020636164 0.00020636288) +(display) +(textposition 'center 'bottom) +(message "smoothlog_nosmooth") +(textsleep) +(usleep 3000000) + + +(outcoloring 9) +(message "smoothlog_smooth") +(textsleep) +(usleep 3000000) +(display) + +(outcoloring 10) +(message "smoothlog_smoothlog") +(textsleep) +(usleep 3000000) +(display) +(usleep 3000000) + +