Fixed tricorn_V3.c to adjust mathematical direction based on height sign

This commit is contained in:
Nikola
2026-07-03 21:10:42 +02:00
parent 5c5b11bece
commit c1bbaf7eda
2 changed files with 3 additions and 1 deletions
+2 -1
View File
@@ -16,6 +16,7 @@ static unsigned converge(float complex position,unsigned n);
void tricorn_V3(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){
// Absolute height for iteration purposes
unsigned imag_direction = height < 0 ? -1 : 1;
height = height < 0 ? height*-1 : height;
unsigned bytesPerColor = color ? 3 : 1;
@@ -23,7 +24,7 @@ void tricorn_V3(float complex start, size_t width, ssize_t height, float res, un
for(size_t i = 0; i < width; i++){
for(ssize_t j = 0; j < height; j++){
unsigned value = converge(start + (i*res - I*j*res),n);
unsigned value = converge(start + (i*res - imag_direction*j*res),n);
// Pixel value position in the output array
size_t position = (j*width +i) * bytesPerColor;