Last active
March 17, 2020 04:32
-
-
Save lukakostic/a9e5188cf41d00d3649b0e41c2085e87 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
#define D fputc(i*8,f) //colors (max = 248=31*8) with 31 iterations | |
main(){ | |
int h=4000,w=4000,a=w*h,i; //resolution | |
FILE*f=fopen("img.ppm","wb"); | |
fprintf(f,"P6\n%d %d\n255\n",w,h); //ppm header: P6 w h colorMax | |
for(;a--;i=31){ //iterations (31) per each pixel (x) | |
for(double t,x=.0,y=.0;x*x+y*y<4.&&i-->1;) //limit (4=2^2) | |
t=x*x-y*y+(a%w-w/2.)*.0006-.5, //x zoom (*.0006) & view (-.5) | |
y=2.*x*y+(a/w-h/2.)*.0006+.0, //y zoom (*.0006) & view (+.0) | |
x=t; //z=z^2+c (cx, cy = pixels scaled to view (-1.,1.) for 4k*4k) | |
D,D,D; //place r,g,b bytes | |
}} |
Author
lukakostic
commented
Mar 17, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment