Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //g++ -o hexa hexa.cpp -lX11 -L/usr/X6R11/lib -l /usr/X6R11/include
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include <X11/Xlib.h>
- #include <assert.h>
- #include <unistd.h>
- #define NIL (0)
- using namespace std;
- int main(){
- Display *dpy = XOpenDisplay(NIL);
- assert(dpy);
- int blackColor = BlackPixel(dpy,DefaultScreen(dpy));
- int whiteColor = WhitePixel(dpy,DefaultScreen(dpy));
- printf("Window height, width: \n");
- int height,width;
- scanf("%d %d",&height,&width);
- printf("Window Layout, 0 = white, 1 = black: ");
- int input;
- scanf("%d",&input);
- if(input == 1){
- Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,blackColor,blackColor);
- XSelectInput(dpy,w,StructureNotifyMask);
- XMapWindow(dpy,w);
- GC gc = XCreateGC(dpy,w,0,NIL);
- XSetForeground(dpy,gc,whiteColor);
- } else if(input==0){
- Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,whiteColor,whiteColor);
- XSelectInput(dpy,w,StructureNotifyMask);
- XMapWindow(dpy,w);
- GC gc = XCreateGC(dpy,w,0,NIL);
- XSetForeground(dpy,gc,blackColor);
- } else {
- printf("%d not found...\nError\n",&input);
- return input;
- }
- for(;;){
- XEvent e;
- XNextEvent(dpy,&e);
- if(e.type == MapNotify)
- break;
- }
- //Main goes here...
- double r,a;
- cout << "Repeat: ";
- cin >> r;
- cout << "Amount: ";
- cin >> 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);
- }
- }
- XFlush(dpy);
- sleep(1);
- }
- cin.ignore().get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement