Fixed: Made negative sign handling and according direction consistent across all implemenatations
This commit is contained in:
@@ -17,22 +17,23 @@ void tricorn_V2(float complex start, size_t width, ssize_t height, float res, un
|
||||
int bytesPerColor = color ? 3 : 1;
|
||||
|
||||
// Absolute height for iteration purposes
|
||||
ssize_t actual_height = height < 0 ? (ssize_t)(-height) : height;
|
||||
ssize_t imag_step = height < 0 ? -1:1;
|
||||
ssize_t actual_height = height > 0 ? height : (ssize_t)(-height);
|
||||
|
||||
// Depending on the sign of height we generate the image top-down or bottom up
|
||||
// As we iterate from the top always, if it is negative we would have to start at the end of the imaginary part and go in the oposite direction when generating
|
||||
ssize_t imag_direction = height < 0 ? -1 : 1;
|
||||
float c_start_real = creal(start);
|
||||
float c_start_imag = cimag(start);
|
||||
float c_start_imag = height > 0 ? cimag(start) : creal(start) + (imag_direction * height * res);;
|
||||
|
||||
float c_imag = c_start_imag;
|
||||
float vertical_step = imag_step * res;
|
||||
|
||||
float vertical_step = imag_direction * res;
|
||||
size_t position = 0;
|
||||
|
||||
|
||||
float c_imag = c_start_imag;
|
||||
// Simple iteration over every pixel in the picture
|
||||
for(ssize_t y = 0; y < actual_height; y++){
|
||||
|
||||
// Calculate imaginary part on each row as it stays the same
|
||||
|
||||
float c_real = c_start_real;
|
||||
for(size_t x = 0; x < width; x++){
|
||||
unsigned value = converge(c_real,c_imag,n);
|
||||
@@ -52,7 +53,7 @@ void tricorn_V2(float complex start, size_t width, ssize_t height, float res, un
|
||||
c_real += res;
|
||||
|
||||
}
|
||||
c_imag -= vertical_step;
|
||||
c_imag += vertical_step;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user