#include #include #include #include #include #define PREFIX "img-" #define VENTANA_ANCHO 1920 #define VENTANA_ALTO 1080 #define ANCHO VENTANA_ANCHO #define ALTO VENTANA_ALTO #define MAX_ITER 500 //long double xc = -1.740119020442992652289958266376L; //long double yc = 0.028019209975637676263081582255L; long double xc = 0.264226442163892496529931097626331393L, yc = 0.002572261418806922467217290773078275; uint32_t computar_intensidad(long double x0, long double y0, long double zoom) { //x0 = x0 * zoom - 1.7400623825793398724575; // Derecha: Achicar //y0 = y0 * zoom + 0.0281753397792111; // Abajo: Achicar x0 = x0 * zoom + xc; // Derecha: Achicar y0 = y0 * zoom + yc; // Abajo: Achicar //x0 = x0 * zoom - 1.78; // Derecha: Achicar //y0 = y0 * zoom + 0.0; // Abajo: Achicar long double x = 0; long double y = 0; int n = 0; while(x*x + y*y <= 4 && n < MAX_ITER) { long double xtemp = x*x - y*y + x0; y = 2*x*y + y0; x = xtemp; n++; } if(n == MAX_ITER) return 0; //float h = (n + 1 - log(log2(sqrt(x*x+y*y)))) / MAX_ITER * 360; //float h = n * 360.0 / MAX_ITER; float h = (int)(n * 360.0 / 50) % 360; float xxx = (1 - fabs(fmodf(h / 60.0, 2) - 1)); uint8_t xx = (xxx < 1 ? xxx : 1) * 255; uint8_t r = 0, g = 0, b = 0; if(h < 60) r = 255, g = xx; else if(h < 120) g = 255, r = xx; else if(h < 180) g = 255, b = xx; else if(h < 240) b = 255, g = xx; else if(h < 300) b = 255, r = xx; else r = 255, b = xx; return (r << 24) | (g << 16) | (b << 8); } int main() { long double zoom = 0.179; double factor = 0.99; int i = 0; while(1) { if(zoom < 1e-20) break; zoom *= factor; printf("%d\n", i); char aux[100]; sprintf(aux, "%s%05d.ppm", PREFIX, i); FILE *f = fopen(aux, "wt"); fprintf(f, "P3\n%d %d\n255\n", ANCHO, ALTO); for(int vy = ALTO / 2; vy > - ALTO / 2; vy--) for(int vx = - ANCHO / 2; vx < ANCHO / 2; vx++) { uint32_t c = computar_intensidad(vx, vy, zoom); fprintf(f, "%d %d %d\n", c >> 24, (c >> 16) & 0xFF, (c >> 8) & 0xFF); } fclose(f); sprintf(aux, "convert %s%05d.ppm %s%05d.png; rm %s%05d.ppm", PREFIX, i, PREFIX, i, PREFIX, i); system(aux); i++; } system("ffmpeg -y -framerate 24 -i " PREFIX "%05d.png -c:v libx264 -crf 0 output.mp4"); return 0; }