Added lookup table for the colors for optimization
Made test output a bit prettier Made tests run function 10 times for higher accuracy
This commit is contained in:
@@ -16,6 +16,15 @@ static unsigned converge(float c_real, float c_imag, unsigned n);
|
||||
*/
|
||||
void tricorn(float complex start, size_t width, ssize_t height, float res, unsigned n, _Bool color, unsigned char* img){
|
||||
int bytesPerColor = color ? 3 : 1;
|
||||
unsigned char color_lookup_table[256][3];
|
||||
if(color) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
color_lookup_table[i][0] = (unsigned char)((i * 3) % 255);
|
||||
color_lookup_table[i][1] = (unsigned char)((i * 2) % 255);
|
||||
color_lookup_table[i][2] = (unsigned char)((i * 5) % 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Absolute height for iteration purposes
|
||||
ssize_t actual_height = height < 0 ? (ssize_t)(-height) : height;
|
||||
@@ -86,9 +95,9 @@ void tricorn(float complex start, size_t width, ssize_t height, float res, unsig
|
||||
img[position] = value;
|
||||
}
|
||||
else {
|
||||
img[position] = ((value*3) % 255);
|
||||
img[position + 1] = ((value*2) % 255);
|
||||
img[position + 2] = ((value*5) % 255);
|
||||
img[position] = color_lookup_table[value][0];
|
||||
img[position + 1] = color_lookup_table[value][1];
|
||||
img[position + 2] = color_lookup_table[value][2];
|
||||
}
|
||||
}
|
||||
c_real_vector = _mm_add_ps(c_real_vector,_mm_set1_ps(four_res));
|
||||
|
||||
Reference in New Issue
Block a user