Advertisement
kellex

SC-2

Sep 17th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. //g++ -o hexa hexa.cpp -lX11 -L/usr/X6R11/lib -l /usr/X6R11/include
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <iostream>
  5. #include <X11/Xlib.h>
  6. #include <assert.h>
  7. #include <unistd.h>
  8.  
  9. #define NIL (0)
  10.  
  11. using namespace std;
  12.  
  13. int main(){
  14.  
  15. Display *dpy = XOpenDisplay(NIL);
  16. assert(dpy);
  17.  
  18. int blackColor = BlackPixel(dpy,DefaultScreen(dpy));
  19. int whiteColor = WhitePixel(dpy,DefaultScreen(dpy));
  20.  
  21. printf("Window height, width: \n");
  22. int height,width;
  23. scanf("%d %d",&height,&width);
  24.  
  25. printf("Window Layout, 0 = white, 1 = black: ");
  26. int input;
  27. scanf("%d",&input);
  28.  
  29. if(input == 1){
  30.     Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,blackColor,blackColor);
  31.     XSelectInput(dpy,w,StructureNotifyMask);
  32.     XMapWindow(dpy,w);
  33.  
  34.     GC gc = XCreateGC(dpy,w,0,NIL);
  35.     XSetForeground(dpy,gc,whiteColor);
  36. } else if(input==0){
  37.     Window w = XCreateSimpleWindow(dpy,DefaultRootWindow(dpy),0,0,height,width,0,whiteColor,whiteColor);
  38.     XSelectInput(dpy,w,StructureNotifyMask);
  39.     XMapWindow(dpy,w);
  40.  
  41.     GC gc = XCreateGC(dpy,w,0,NIL);
  42.     XSetForeground(dpy,gc,blackColor);
  43. } else {
  44.     printf("%d not found...\nError\n",&input);
  45.     return input;
  46. }
  47.  
  48. for(;;){
  49.     XEvent e;
  50.     XNextEvent(dpy,&e);
  51.     if(e.type == MapNotify)
  52.         break;
  53. }
  54.  
  55. //Main goes here...
  56.     double r,a;
  57.     cout << "Repeat: ";
  58.     cin >> r;
  59.     cout << "Amount: ";
  60.     cin >> a;
  61.  
  62.     for(double yi=0;yi<r;yi++){
  63.         yi=sin(yi);
  64.         yi=yi*a;
  65.         for(double xi=0;xi<r;xi++){
  66.             xi=sin(xi);
  67.             xi=xi*a;
  68.             XDrawPoint(dis,win,gc,xi,yi);
  69.         }
  70.     }
  71.  
  72.     XFlush(dpy);
  73.     sleep(1);
  74. }
  75. cin.ignore().get();
  76.  
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement