chiark / gitweb /
b724594e676253fef6a5bb80082704495b67838a
[moebius.git] / x11.cc
1 /*
2  * X11 functions
3  */
4
5
6 #include "x11.hh"
7
8 X11Output::X11Output() {
9   XGCValues gcvalues;
10   display= XOpenDisplay(0);
11   window= XCreateSimpleWindow(display,
12                               DefaultRootWindow(display),
13                               0,0, 500,500, 0,0,0);
14   gcvalues.background= 0;
15   fabric= XCreateGC(display,window,GCBackground,&gcvalues);
16   gcvalues.foreground= 1;
17   gcvalues.background= 1;
18   mesh= XCreateGC(display,window,GCForeground|GCBackground,&gcvalues);
19   XSelectInput(display,window,0);
20   XMapWindow(display,window);
21   XFlush(display);
22 }
23
24 void X11Output::startimage() {
25   XClearWindow(display,window);
26 }
27
28 void X11Output::endimage() {
29   XFlush(display);
30 }
31
32 X11Output::~X11Output() {
33   XCloseDisplay(display);
34 }
35
36 void X11Output::drawcell(const Point* list, int n) {
37   XPoint xp[n+1];
38   for (int i=0; i<n; i++) {
39     Onscreen here= Onscreen(list[i]);
40     xp[i].x= (int)((here.x+1.0)*250.0);
41     xp[i].y= (int)((-here.y+1.0)*250.0);
42   }
43   XFillPolygon(display,window,fabric,xp,n,Nonconvex,CoordModeOrigin);
44   xp[n]= xp[0];
45   XDrawLines(display,window,mesh,xp,n+1,CoordModeOrigin);
46 }