Budhha
Budhha
Budhha
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
////////////////////////////////////////////////////////////////////////////////////
#undef RANDOM_SOURCE
#define OPTIMISE // Don't bother iterating some values obviously in the set.
#define reduce(foo) (foo) // Macro to reduce colours, can use sqrt(n), log(n), etc, or
just (n)
////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
int iterations;
////////////////////////////////////////////////////////////////////////////////////
iterations = RED_ITERATIONS_UPPER;
if (GREEN_ITERATIONS_UPPER > iterations) iterations =
GREEN_ITERATIONS_UPPER;
if (BLUE_ITERATIONS_UPPER > iterations) iterations =
BLUE_ITERATIONS_UPPER;
// Main bit...
x = SOURCE_LEFT_X;
for (source_column = 0; source_column < SOURCE_COLUMNS;
source_column++, x += x_jump)
{
y = SOURCE_TOP_Y;
for (source_row = 0; source_row < SOURCE_ROWS; source_row++, y
+= y_jump)
{
#ifdef OPTIMISE
if
(
(x > -1.2 && x <= -1.1 && y > -0.1 && y < 0.1)
|| (x > -1.1 && x <= -0.9 && y > -0.2 && y < 0.2)
|| (x > -0.9 && x <= -0.8 && y > -0.1 && y < 0.1)
|| (x > -0.69 && x <= -0.61 && y > -0.2 && y < 0.2)
|| (x > -0.61 && x <= -0.5 && y > -0.37 && y < 0.37)
|| (x > -0.5 && x <= -0.39 && y > -0.48 && y < 0.48)
|| (x > -0.39 && x <= 0.14 && y > -0.55 && y < 0.55)
|| (x > 0.14 && x < 0.29 && y > -0.42 && y < -0.07)
|| (x > 0.14 && x < 0.29 && y > 0.07 && y < 0.42)
) continue;
#endif
r = 0; s = 0;
for (n = 0; n <= iterations; n++)
{
nextr = ((r * r) - (s * s)) + x;
nexts = (2 * r * s) + y;
r = nextr;
s = nexts;
if (n == iterations)
{
// drawpath(x, y, target_startx, target_starty,
pixel_width);
break;
} else if ((r * r) + (s * s) > 4) {
drawpath(x, y, target_startx, target_starty,
pixel_width);
break;
}
}
if (source_column % UPDATETICK == 0)
{
printf("Reached source column: %d of %d\n", source_column,
SOURCE_COLUMNS);
}
r = 0; s = 0;
for (n = 0; n <= iterations; n++)
{
nextr = ((r * r) - (s * s)) + x;
nexts = (2 * r * s) + y;
r = nextr;
s = nexts;
}
return;
}
// Headers...
// Note that the "BM" identifier in bytes 0 and 1 is NOT included in these "headers".
headers[7] = 0; // biCompression
headers[8] = paddedsize; // biSizeImage
headers[9] = 0; // biXPelsPerMeter
headers[10] = 0; // biYPelsPerMeter
headers[11] = 0; // biClrUsed
headers[12] = 0; // biClrImportant
//
// Headers begin...
// When printing ints and shorts, we write out 1 character at a time to avoid endian issues.
//
fprintf(outfile, "BM");
// These next 4 characters are for the biPlanes and biBitCount fields.
//
// Headers done, now write the data...
//
for (y = HEIGHT - 1; y >= 0; y--) // BMP image format is written from bottom to top...
{
for (x = 0; x <= WIDTH - 1; x++)
{
fclose(outfile);
return;
}