#include <iostream>
#include <cmath>
#include <cstdlib>
#define DIM 1024
#define DM1 (DIM-1)
#define _sq(x) ((x)*(x)) // square
#define _cb(x) abs((x)*(x)*(x)) // absolute value of cube
#define _cr(x) (unsigned char)(pow((x),1.0/3.0)) // cube root unsigned char GR(int,int);
unsigned char BL(int,int); unsigned char RD(int i,int j){
float s=./(j+);
float y=(j+sin((i*i+_sq(j-)*)/./DIM)*)*s;
return (int((i+DIM)*s+y)%+int((DIM*-i)*s+y)%)*;
}
unsigned char GR(int i,int j){
float s=./(j+);
float y=(j+sin((i*i+_sq(j-)*)/./DIM)*)*s;
return (int(*((i+DIM)*s+y))%+int(*((DIM*-i)*s+y))%)*;
}
unsigned char BL(int i,int j){
float s=./(j+);
float y=(j+sin((i*i+_sq(j-)*)/./DIM)*)*s;
return (int(*((i+DIM)*s+y))%+int(*((DIM*-i)*s+y))%)*;
}
void pixel_write(int,int);
FILE *fp;
int main(){
fp = fopen("MathPic.png","wb");
fprintf(fp, "P6\n%d %d\n255\n", DIM, DIM);
for(int j=;j<DIM;j++)
for(int i=;i<DIM;i++)
pixel_write(i,j);
fclose(fp);
return ;
}
void pixel_write(int i, int j){
static unsigned char color[];
color[] = RD(i,j)&;
color[] = GR(i,j)&;
color[] = BL(i,j)&;
fwrite(color, , , fp);
}
# 上边代码保存为 draw.cpp 编译与运行 g++ draw.cpp -o draw (编译) ./draw (运行) 然后当前目录就会出现 MathPic.png
http://www.matrix67.com/blog/archives/6039
http://codegolf.stackexchange.com/questions/35569/tweetable-mathematical-art