Skip to content

Commit

Permalink
Merge pull request #253 from iaoesch/osi_added_log_colorizing_in_smooth
Browse files Browse the repository at this point in the history
Added logarithmic smooth colorizing
  • Loading branch information
kovzol authored Jul 30, 2024
2 parents 17d0f46 + 4108866 commit a191d66
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 29 deletions.
2 changes: 2 additions & 0 deletions XaoS.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 29 additions & 0 deletions catalogs/de.cat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions catalogs/en.cat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
41 changes: 29 additions & 12 deletions src/engine/formulas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const char *const outcolorname[] = {"iter",
"potential",
"color decomposition",
"smooth",
"smooth log",
"True-color",
NULL};

Expand Down Expand Up @@ -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() \
Expand All @@ -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(); \
Expand All @@ -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)) \
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
},
{
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down
6 changes: 3 additions & 3 deletions src/engine/fractal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
37 changes: 34 additions & 3 deletions src/include/fractal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,6 +93,8 @@ struct formula {
int flags;
};



struct fractal_context {
number_t pre, pim;
number_t bre, bim;
Expand All @@ -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;
Expand Down Expand Up @@ -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; \
Expand Down
5 changes: 3 additions & 2 deletions src/ui-hlp/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}

Expand Down
Loading

0 comments on commit a191d66

Please sign in to comment.