#ifndef _FRAK_H_ #define _FRAK_H_ 1 #include #include #include #include #include #include #define PIXMAP_WIDTH 640 /* default pixmap size */ #define PIXMAP_HEIGHT 480 #define PREVIEW_SCALE 0.33 /* preview pixmap will smaller than the main one by 1/PREVIEW_SCALE */ #define DEFAULT_MAXITER 100 /* default iteration limit */ #define SCROLLING_STEP 0.1 /* scrolling step - proportion of screen */ #define SCALE_STEP 2 /* scale step */ #define DEFAULT_SCALE_MANDELBROT 0.75 #define DEFAULT_SCALE 0.375 /* canonical view - scale */ #define DEFAULT_CENTERX -0.5 /* canonical view - home coordinates */ #define DEFAULT_CENTERY 0 /* --||-- */ #define PALETTE_SIZE 256 #define SCREENSHOT_FILENAME_SIZE 255 #define SCREENSHOT_EXT ".tga" #define WINDOW_TITLE "Frak" typedef struct { unsigned int width; unsigned int height; unsigned char * pixels; } pixmap; /* ------------------------- ------------------------- */ extern pixmap * pixMain; /* big pixmap for Mandelbrot or Julia set */ extern pixmap * pixPreview; /* small pixmap for Julia preview mode (maybe also for orbits mode in future...) */ extern unsigned char needsRecalcMain; /* pixMain needs to be recalculated */ extern unsigned char needsRecalcPreview; /* pixPreview needs to be recalculated */ extern unsigned char needsCompleteRecalcMain; /* force recalc, even when pixmap can be moved */ extern unsigned char enablePixmove; /* enable pixmove optimization */ extern unsigned char juliaPreviewMode; /* small preview of Julia set */ extern unsigned char juliaMode; /* Julia set instead of Mandelbrot set */ extern unsigned char calculatingMain; /* pixMain is being calculated - keys must wait */ extern unsigned int maxiter; /* center of current scene - complex coordinates */ extern double centerx, centery; extern double scale; /* previous scene parameters - used by the pixmove optimization */ extern double prevcenterx, prevcentery; extern double prevscale; extern double jx, jy; /* Julia parameters */ extern unsigned int width, height; /* pixMain/window width & height */ extern unsigned char mousedown; extern unsigned char palette[PALETTE_SIZE][3]; /* pallete - dynamicly generate */ extern char screenshotFile[]; extern char screenshotExt[]; extern char screenshotPrefix[]; /* ------------------------- FUNCTIONS ------------------------- */ void generatePalette(void); void colorize(const int iter, const int maxiter, const double zx, const double zy, unsigned char *r, unsigned char *g, unsigned char *b); void calcMandelbrotSet(pixmap *p, double centerx, double centery, double scale, int maxiter, int fromx, int fromy, int tox, int toy); void calcJuliaSet(pixmap *p, double centerx, double centery, double scale, int maxiter, double jx, double jy); void calc(void); int filenameFilter(const struct dirent *filename); void nextFileNumber (char * filename); void onExit(void); void onInit(void); void onResize(int w, int h); void onDisplay(void); void onKeyboard(unsigned char key, int x, int y); void onKeyboardSpecial(int key, int x, int y); void onMouse(int button, int state, int x, int y); void onMouseMotion(int x, int y); pixmap * createPixmap(int width, int height); void deletePixmap(pixmap *p); void clearPixmap(pixmap *p); void putpixel(pixmap *p, const unsigned int x, const unsigned int y, const unsigned char r, const unsigned char g, const unsigned char b); void drawPixmap(const pixmap *p, const int xoff, const int yoff); int savePixmapTGA(const pixmap *p, const char * fileName); int pixmove(const pixmap * p, int xoff, int yoff); void pixmapInit(void); #endif /* _FRAK_H_*/