Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* include the X library headers */
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Xos.h>
- /* include some silly stuff */
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- /* here are our X variables */
- Display *dis;
- int screen;
- Window win;
- GC gc;
- /* here are our X routines declared! */
- void init_x();
- void close_x();
- void redraw();
- main () {
- XEvent event; /* the XEvent declaration !!! */
- KeySym key; /* a dealie-bob to handle KeyPress Events */
- char text[255]; /* a char buffer for KeyPress Events */
- init_x();
- double r,a;
- printf("Repeat: ");
- scanf("%d",&r);
- printf("Amount: ");
- scanf("%d",&a);
- for(double yi=0;yi<r;yi++){
- yi=sin(yi);
- yi=yi*a;
- for(double xi=0;xi<r;xi++){
- xi=sin(xi);
- xi=xi*a;
- XDrawPoint(dis,win,gc,xi,yi);
- }
- }
- getchar();
- sleep(5);
- close_x();
- }
- void init_x() {
- /* get the colors black and white (see section for details) */
- unsigned long black,white;
- dis=XOpenDisplay((char *)0);
- screen=DefaultScreen(dis);
- black=BlackPixel(dis,screen),
- white=WhitePixel(dis, screen);
- printf("Window height, width: ");
- int height,width;
- scanf("%d %d",&height,&width);
- win=XCreateSimpleWindow(dis,DefaultRootWindow(dis),0,0,height, width, 5,black, white);
- XSetStandardProperties(dis,win,"x11lib","template",None,NULL,0,NULL);
- XSelectInput(dis, win, ExposureMask|ButtonPressMask|KeyPressMask);
- gc=XCreateGC(dis, win, 0,0);
- XSetBackground(dis,gc,white);
- XSetForeground(dis,gc,black);
- XClearWindow(dis, win);
- XMapRaised(dis, win);
- };
- void close_x() {
- XFreeGC(dis, gc);
- XDestroyWindow(dis,win);
- XCloseDisplay(dis);
- exit(1);
- };
- void redraw() {
- XClearWindow(dis, win);
- };
Advertisement
Add Comment
Please, Sign In to add comment