/* $Id$ * stern.c 25.12.2006 * stern.c 07.02.2004 * STERN.C 11.07.2003 * STERN.CPP 11.02.2000 * STERN.BAS 29.04.1996 */ #include #include #include #include #include int Calc3D(int *, int *, int *); void DrawObject(int); void MainLoop(void); #define Usleep 10000 #define Width 800 #define Height 600 #define Pi 3.1415926 #define SECOND #if defined(FIRST) #define D 500 #define Lines 24 static int World[Lines][3] = { 50, 50, 50, -50, 50, 50, 50,-50, 50, -50,-50, 50, 50, 50,-50, -50, 50,-50, 50,-50,-50, -50,-50,-50, 50, 50, 50, 50,-50, 50, -50, 50, 50, -50,-50, 50, 50, 50,-50, 50,-50,-50, -50, 50,-50, -50,-50,-50, 50, 50, 50, 50, 50,-50, 50,-50, 50, 50,-50,-50, -50,-50, 50, -50,-50,-50, -50, 50, 50, -50, 50,-50 }; #elif defined(SECOND) #define D 200 #define Lines 36 static int World[Lines][3] = { -60, 40, 20, -20, 40, 20, -20, 40, 20, -20, 0, 20, -20, 0, 20, 60, 0, 20, 60, 0, 20, 60,-40, 20, 60,-40, 20, -60,-40, 20, -60,-40, 20, -60, 40, 20, -60, 40,-20, -20, 40,-20, -20, 40,-20, -20, 0,-20, -20, 0,-20, 60, 0,-20, 60, 0,-20, 60,-40,-20, 60,-40,-20, -60,-40,-20, -60,-40,-20, -60, 40,-20, -60, 40, 20, -60, 40,-20, -20, 40, 20, -20, 40,-20, -20, 0, 20, -20, 0,-20, 60, 0, 20, 60, 0,-20, 60,-40, 20, 60,-40,-20, -60,-40, 20, -60,-40,-20 }; #else #define D 300 #define Lines 72 static int World[Lines][3] = { 90, 0, 0, 10, 10, 10, 90, 0, 0, 10, 10,-10, 90, 0, 0, 10,-10,-10, 90, 0, 0, 10,-10, 10, -90, 0, 0, -10, 10, 10, -90, 0, 0, -10, 10,-10, -90, 0, 0, -10,-10,-10, -90, 0, 0, -10,-10, 10, 0, 90, 0, 10, 10, 10, 0, 90, 0, -10, 10, 10, 0, 90, 0, -10, 10,-10, 0, 90, 0, 10, 10,-10, 0,-90, 0, 10,-10, 10, 0,-90, 0, -10,-10, 10, 0,-90, 0, -10,-10,-10, 0,-90, 0, 10,-10,-10, 0, 0, 90, 10, 10, 10, 0, 0, 90, 10,-10, 10, 0, 0, 90, -10,-10, 10, 0, 0, 90, -10, 10, 10, 0, 0,-90, 10, 10,-10, 0, 0,-90, 10,-10,-10, 0, 0,-90, -10,-10,-10, 0, 0,-90, -10, 10,-10, 10, 10, 10, -10, 10, 10, 10,-10, 10, -10,-10, 10, 10, 10,-10, -10, 10,-10, 10,-10,-10, -10,-10,-10, 10, 10, 10, 10,-10, 10, -10, 10, 10, -10,-10, 10, 10, 10,-10, 10,-10,-10, -10, 10,-10, -10,-10,-10, 10, 10, 10, 10, 10,-10, 10,-10, 10, 10,-10,-10, -10,-10, 10, -10,-10,-10, -10, 10, 10, -10, 10,-10 }; #endif Display *display; Window win; GC gc; /* XGCValues values; */ int main(void) { int screen; int black, white; int r = 0; display = XOpenDisplay(NULL); screen = DefaultScreen(display); black = BlackPixel(display, screen); white = WhitePixel(display, screen); win = XCreateSimpleWindow(display, DefaultRootWindow(display), 0, 0, Width, Height, 0, black, white); XMapWindow(display, win); gc = XCreateGC(display, win, 0, NULL); XSetForeground(display, gc, black); XSetBackground(display, gc, white); XSetLineAttributes(display, gc, 2, LineSolid, CapButt, JoinBevel); XSetFillStyle(display, gc, FillSolid); XSelectInput(display, win, StructureNotifyMask); for (;;) { XEvent event; XNextEvent(display, &event); if (event.type == MapNotify) break; } for (;;) { if (r >= 360) r = 0; XClearWindow(display, win); DrawObject(++r); XFlush(display); usleep(Usleep); } XCloseDisplay(display); return 0; } float Sr, Cr; void DrawObject(int r) { float R; int i; int x1, y1, x2, y2; R = Pi * r / 180; Sr = sin(R); Cr = cos(R); for(i=0; i