/* Sequential Mandelbrot program */ #include #include #include #include #include #include #define X_RESN 800 /* x resolution */ #define Y_RESN 800 /* y resolution */ #define MAX_COLORS 256 /* #define MAX_COLORS 100 */ typedef struct complextype { float real, imag; } Compl; int main () { Window win; /* initialization for a window */ unsigned int width, height, /* window size */ x, y, /* window position */ border_width, /*border width in pixels */ display_width, display_height, /* size of screen */ screen; /* which screen */ char *window_name = "Mandelbrot Set", *display_name = NULL; GC gc; unsigned long valuemask = 0; XGCValues values; Display *display; XSizeHints size_hints; Pixmap bitmap; XPoint points[800]; FILE *fp, *fopen (); char str[100]; Colormap colormap; XColor colors[MAX_COLORS]; XSetWindowAttributes attr[1]; /* Mandlebrot variables */ int i, j, k; Compl z, c; float lengthsq, temp; /* connect to Xserver */ if ( (display = XOpenDisplay (display_name)) == NULL ) { fprintf (stderr, "drawon: cannot connect to X server %s\n", XDisplayName (display_name) ); exit (-1); } /* get screen size */ screen = DefaultScreen (display); display_width = DisplayWidth (display, screen); display_height = DisplayHeight (display, screen); /* set window size */ width = X_RESN; height = Y_RESN; /* set window position */ x = 0; y = 0; /* create opaque window */ border_width = 4; win = XCreateSimpleWindow (display, RootWindow (display, screen), x, y, width, height, border_width, BlackPixel (display, screen), WhitePixel (display, screen)); size_hints.flags = USPosition|USSize; size_hints.x = x; size_hints.y = y; size_hints.width = width; size_hints.height = height; size_hints.min_width = 300; size_hints.min_height = 300; XSetNormalHints (display, win, &size_hints); XStoreName(display, win, window_name); colormap = DefaultColormap(display, DefaultScreen(display)); /*if you want regist colors by value, please do this * for(i=0; i