Allow moving C=A+B.i in the complex plan with [SHIFT+ARROWs] for the Julia set

This commit is contained in:
Sylvain PILLOT 2023-01-19 13:19:26 +01:00
parent 95948ca747
commit 434195fee8
5 changed files with 48 additions and 13 deletions

View File

@ -11,6 +11,7 @@ Both Mandelbrot - *named as per Benoît MANDELBROT (1924-2010)* - and Julia - *n
## What can we do ?
Control keys are :
[**EXIT**] to leave to the Operating System
[**F1**] to [**F4**] to show/switch off some informations on the screen :
- [ ] [F1] : hide everything
@ -24,4 +25,13 @@ Control keys are :
- [ ] [OPTN] : set resolution scale to 1, the fractals are computed on a 396x224 grid
- [ ] [VARS] : set resolution scale to 0.5 (2x2 pixels), the fractals are computed on a 198x112 grid (much faster but lower quality)
Have fun !!!
For the Julia set only :
[**SHIFT**]+[**Directional Cross**] : change the value of the C value (`C = A + B i`)
- [ ] [**SHIFT+LEFT**] : A = A - 0.002
- [ ] [**SHIFT+RIGHT**] : A = A + 0.002
- [ ] [**SHIFT+DOWN**] : B = B - 0.002
- [ ] [**SHIFT+UP**] : B = B + 0.002
A and B are constrained in the range [-2.000 .. 2.000]
Have fun !!!

View File

@ -6,7 +6,7 @@ void azrp_mandelbrot_init( void );
void azrp_mandelbrot_close( void );
void azrp_mandelbrot_USBDEBUG( void );
void azrp_julia( void );
void azrp_julia( float cr, float ci );
void azrp_julia_init( void );
void azrp_julia_close( void );
void azrp_julia_USBDEBUG( void );

View File

@ -58,12 +58,14 @@ struct command {
libnum::num xmax;
libnum::num ymin;
libnum::num ymax;
libnum::num cr;
libnum::num ci;
libnum::num xinc;
libnum::num yinc;
};
void azrp_julia( void )
void azrp_julia( float cr, float ci )
{
prof_enter(azrp_perf_cmdgen);
@ -77,6 +79,9 @@ void azrp_julia( void )
cmd.ymax = libnum::num(1.12f);
cmd.xinc = libnum::num((2*1.98f)/azrp_width);
cmd.yinc = libnum::num((2*1.12f)/azrp_height);
cmd.cr = libnum::num(cr);
cmd.ci = libnum::num(ci);
int fragmin = 0;
int fragcount = (azrp_height >> 4) + 1;
@ -84,9 +89,6 @@ void azrp_julia( void )
prof_leave(azrp_perf_cmdgen);
}
extern "C" {
extern int julia(int32_t cr, int32_t ci, uint32_t t_squared, int steps, int32_t zr, int32_t zi);
}
void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
{
@ -98,8 +100,8 @@ void azrp_shader_julia( void *uniforms, void *comnd, void *fragment )
libnum::num zr, zr2;
libnum::num zi, zi2;
libnum::num cr = libnum::num(-0.480f);
libnum::num ci = libnum::num(0.600f);
libnum::num cr = cmd->cr;
libnum::num ci = cmd->ci;
libnum::num zrsave = cmd->xmin;
libnum::num zisave = cmd->ymax - libnum::num(cmd->current_frag*16)*cmd->yinc;

View File

@ -35,6 +35,7 @@ int SCALE_PIXEL=2;
uint8_t texttodraw=2;
uint8_t Mandel_Julia_Switch = 1;
float Cr, Ci;
void do_nothing( void )
@ -56,7 +57,7 @@ static void get_inputs( void )
}
if(keydown(KEY_SHIFT)) { }
if(keydown(KEY_EXIT)) {exitToOS = true; };
@ -90,6 +91,26 @@ static void get_inputs( void )
azrp_julia_init();
};
if(Mandel_Julia_Switch==2)
{
if(keydown(KEY_SHIFT) && keydown(KEY_LEFT))
{
if(Cr>-2.0f) Cr-=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_RIGHT))
{
if(Cr<2.0f) Cr+=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_DOWN))
{
if(Ci>-2.0f) Ci-=0.002;
}
else if(keydown(KEY_SHIFT) && keydown(KEY_UP))
{
if(Ci<2.0f) Ci+=0.002;
}
}
if(keydown(KEY_F1)) {texttodraw=0;}
if(keydown(KEY_F2)) {texttodraw=1;}
if(keydown(KEY_F3)) {texttodraw=2;}
@ -101,6 +122,10 @@ static void get_inputs( void )
int main(void)
{
Cr = -0.480f;
Ci = 0.600f;
exitToOS = false;
float elapsedTime = 0.0f;
@ -153,10 +178,11 @@ int main(void)
azrp_clear( C_BLACK );
if (Mandel_Julia_Switch==1) azrp_mandelbrot();
else if(Mandel_Julia_Switch==2) azrp_julia();
else if(Mandel_Julia_Switch==2) azrp_julia(Cr,Ci);
else do_nothing();
if (texttodraw>=1) Azur_draw_text(1,01, " FPS = %.0f - Render = %.0f", (float) (1000000.0f / elapsedTime), (float) time_render / 1000.0f );
if (texttodraw>=1 && Mandel_Julia_Switch==2) Azur_draw_text(1,11, " Cr = %.3f - Ci = %.3f", Cr, Ci );
if (texttodraw>=2) Azur_draw_text(1,31, "Update = %.0f mc secs", (float) time_update );
if (texttodraw>=2) Azur_draw_text(1,41, "Render = %.0f mc secs", (float) time_render );
if (texttodraw>=2) Azur_draw_text(1,51, ">Total = %.3f ml secs", (float) elapsedTime / 1000.0f );

View File

@ -84,9 +84,6 @@ void azrp_mandelbrot( void )
prof_leave(azrp_perf_cmdgen);
}
extern "C" {
extern int mandelbrot(int32_t cr, int32_t ci, uint32_t t_squared, int steps);
}
void azrp_shader_mandelbrot( void *uniforms, void *comnd, void *fragment )
{