Skip to content

Commit 9350fc0

Browse files
author
PythonGermany
committed
Nothing
1 parent 3ecfdaa commit 9350fc0

File tree

5 files changed

+49
-12
lines changed

5 files changed

+49
-12
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# By: rburgsta <[email protected]. +#+ +:+ +#+ #
77
# +#+#+#+#+#+ +#+ #
88
# Created: 2022/11/25 15:38:03 by rburgsta #+# #+# #
9-
# Updated: 2022/11/29 22:21:52 by rburgsta ### ########.fr #
9+
# Updated: 2022/11/30 02:30:14 by rburgsta ### ########.fr #
1010
# #
1111
# **************************************************************************** #
1212

colors.c

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,47 @@ uint32_t get_color(int r, int g, int b, int a)
2222
return ((r <<= 24) + (g <<= 16) + (b <<= 8) + (a & 0xFF));
2323
}
2424

25-
uint32_t transform_color_range(t_dta *dta)
25+
uint32_t tcr(int iter, int curr, int cs)
2626
{
2727
int c;
2828

29-
c = range(255 * 6 + 1, dta->iter, (*dta->f)(dta));
29+
c = range(255 * 6 + 1, iter, curr);
3030
if (c == 255 * 6 + 1)
3131
return (get_color(0, 0, 0, 255));
32-
c += dta->cs;
33-
if (c <= 255 && !dta->cs)
32+
c += cs;
33+
if (c <= 255 && !cs)
3434
return (get_color(c, 0, 0, c));
35-
if (c <= 255 && dta->cs)
35+
if (c <= 255 && cs)
3636
return (get_color(255, 0, 255 - c, 255));
3737
if (c <= 255 * 2)
3838
return (get_color(255, c - 255, 0, 255));
3939
if (c <= 255 * 3)
4040
return (get_color(255 * 3 - c, 255 , 0, 255));
4141
if (c <= 255 * 4)
4242
return (get_color(0, 255, c - 255 * 3, 255));
43-
if (c < 255 * 5)
43+
if (c <= 255 * 5)
4444
return (get_color(0, 255 * 5 - c, 255, 255));
4545
return (get_color(c - 255 * 5, 0, 255, 255));
46-
}
46+
}
47+
48+
// uint32_t lin_inter(uint32_t c1, uint32_t c2, double f)
49+
// {
50+
// uint8_t dr;
51+
// uint8_t dg;
52+
// uint8_t db;
53+
// uint8_t da;
54+
55+
// dr = (c2 - c1) << 24;
56+
// dg = (c2 - c1) << 16;
57+
// db = (c2 - c1) << 8;
58+
// da = (c2 - c1) & 0xFF;
59+
// return (get_color((c2 << 24) + dr * f, (c2 << 16) + dg * f,
60+
// (c2 << 8) + db * f, (c2 & 0xFF) + da * f));
61+
62+
// }
63+
64+
// uint32_t interpolate(int iter, double curr, int cs)
65+
// {
66+
// return (lin_inter(tcr(iter, curr, cs),
67+
// tcr(iter, curr + 1, cs), curr - (int)curr));
68+
// }

fractol.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef struct s_dta
3333
double x;
3434
double y;
3535
int cs;
36+
int param[4];
3637
} t_dta;
3738

3839
//Fractals
@@ -41,9 +42,9 @@ int mandelbrot(t_dta *dta);
4142
int tricorn(t_dta *dta);
4243

4344
//Colors
44-
int range(int out_max, int in_max, int in_curr);
4545
uint32_t get_color(int r, int g, int b, int a);
46-
uint32_t transform_color_range(t_dta *dta);
46+
uint32_t tcr(int iter, int curr, int cs);
47+
//uint32_t interpolate(int iter, double curr, int cs);
4748

4849
//Hooks
4950
void key_hook(void *dta);

hooks.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
/* ************************************************************************** */
1212

1313
#include "fractol.h"
14+
#include <stdio.h>
15+
#include <time.h>
16+
17+
int i = 0;
18+
int ms_g = 0;
1419

1520
void key_hook(void *dta)
1621
{
@@ -35,7 +40,15 @@ void key_hook(void *dta)
3540
populate_dta(tmp);
3641
if (mlx_is_mouse_down(tmp->mlx, MLX_MOUSE_BUTTON_RIGHT))
3742
tmp->cs = (tmp->cs % (254 * 6)) + 6;
43+
// clock_t diff;
44+
// clock_t start = clock();
3845
calculate_window(tmp);
46+
// diff = clock() - start;
47+
// int msec = diff * 1000 / CLOCKS_PER_SEC;
48+
// ms_g += msec%1000;
49+
// i++;
50+
// printf("Time taken %d seconds %d milliseconds av: %d\n", msec/1000, msec%1000, ms_g / i);
51+
3952
}
4053

4154
void scroll_hook(double xdelta, double ydelta, void *param)

main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: rburgsta <[email protected]. +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/11/27 16:31:38 by rburgsta #+# #+# */
9-
/* Updated: 2022/11/29 22:23:20 by rburgsta ### ########.fr */
9+
/* Updated: 2022/11/30 02:27:57 by rburgsta ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -94,7 +94,8 @@ void calculate_window(t_dta *dta)
9494
{
9595
dta->x = ((i2 - WIDTH / 2.0) * dta->scale) / WIDTH + dta->xs;
9696
dta->y = ((HEIGHT / 2.0 - i) * dta->scale) / HEIGHT + dta->ys;
97-
mlx_put_pixel(dta->img, i2++, i, transform_color_range(dta));
97+
mlx_put_pixel(dta->img, i2++, i, \
98+
tcr(dta->iter, (*dta->f)(dta), dta->cs));
9899
}
99100
i++;
100101
}

0 commit comments

Comments
 (0)