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));
- Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,1500,1500,0,blackColor,blackColor);
- XSelectInput(dpy,w,StructureNotifyMask);
- XMapWindow(dpy,w);
- GC gc = XCreateGC(dpy,w,0,NIL);
- XSetForeground(dpy,gc,whiteColor);
- for(;;){
- XEvent e;
- XNextEvent(dpy,&e);
- if(e.type == MapNotify)
- break;
- }
- int Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,Ex,Ey,Fx,Fy,r,amount;
- cout << "Ax: "; cin >> Ax; cout << endl;
- cout << "Ay: "; cin >> Ay; cout << endl;
- cout << "Bx: "; cin >> Bx; cout << endl;
- cout << "By: "; cin >> By; cout << endl;
- cout << "Cx: "; cin >> Cx; cout << endl;
- cout << "Cy: "; cin >> Cy; cout << endl;
- cout << "Dx: "; cin >> Dx; cout << endl;
- cout << "Dy; "; cin >> Dy; cout << endl;
- cout << "Ex: "; cin >> Ex; cout << endl;
- cout << "Ey: "; cin >> Ey; cout << endl;
- cout << "Fx: "; cin >> Fx; cout << endl;
- cout << "Fy: "; cin >> Fy; cout << endl;
- cout << "repetitions: "; cin >> r; cout << endl;
- cout << "amount: "; cin >> amount; cout << endl;
- Ax=Ax*100;
- Ay=Ay*100;
- Bx=By*100;
- By=By*100;
- Cx=Cx*100;
- Cy=Cy*100;
- Dx=Dx*100;
- Dy=Dy*100;
- Ex=Ex*100;
- Ey=Ey*100;
- Fx=Fx*100;
- Fy=Fy*100;
- amount=amount*100;
- for(int i=0;i<r;i++){
- XDrawLine(dpy,w,gc,Ax,Ay,Cx,Cy);
- XDrawLine(dpy,w,gc,Cx,Cy,Dx,Dy);
- XDrawLine(dpy,w,gc,Dx,Dy,Bx,By);
- XDrawLine(dpy,w,gc,Bx,By,Ex,Ey);
- XDrawLine(dpy,w,gc,Ex,Ey,Fx,Fy);
- XDrawLine(dpy,w,gc,Fx,Fy,Ax,Ay);
- Cx=Cx+amount;
- Dx=Dx+amount;
- Ex=Ex-amount;
- Fx=Fx-amount;
- XFlush(dpy);
- sleep(1);
- }
- cin.ignore().get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement