ONE LINE SMAFFER FRACTAL GENERATOR

by Sandro Maffiodo

smaffer@gmail.com

www.assezeta.com/sandromaffiodo

OVERVIEW

This is a fractals generator. It generates a fractal like the Sierpinski Carpet but little different.

BUILD

$(CC) prog.c -o prog

RUN

echo 27 | ./prog > image.ppm

To view the generate image you can use GIMP or ImageMagick to convert the image

convert image.ppm image.jpg

FEATURES

This program reads a number N from stdin and generates a PPM image with resolution NxN

SIERPINSKI CARPET in 149 bytes

This is the standard Sierpinski Carpet fractal, if you don't want my fractal:

a,b,c,x,y;main(){scanf("%d",&a);printf("P5 %d %d 1 ",a,a);for(;b!=a*a;b++){x=b%a;y=b/a;c=1;while(c&&x||y){c&=!(x%3&1&&y%3&1);x/=3;y/=3;}putchar(c);}}

REMARKS

The build process will generate some warnings about: