Created
January 24, 2014 16:23
-
-
Save anonymous/8600647 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
#include <unistd.h> | |
#include <cairo-xlib.h> | |
#ifndef M_PI | |
#define M_PI 3.1415926535 | |
#endif | |
const int gWidth = 500; | |
const int gHeight = 500; | |
int main(int argc, char *argv[]) { | |
cairo_surface_t* cs; | |
cairo_t *cr; | |
Display *xDpy; | |
Window window; | |
double angle; | |
struct timeval start, now; | |
xDpy = XOpenDisplay(NULL); | |
window = XCreateSimpleWindow(xDpy, XDefaultRootWindow(xDpy), 0, 0, gWidth, gHeight, 0, 0, 0); | |
XMapWindow(xDpy, window); | |
cs = cairo_xlib_surface_create(xDpy, window, DefaultVisual(xDpy, 0), gWidth, gHeight); | |
gettimeofday(&start, NULL); | |
for(;;) { | |
cr = cairo_create(cs); | |
gettimeofday(&now, NULL); | |
angle = (now.tv_sec - start.tv_usec + (now.tv_usec-start.tv_usec)*1e-6) * M_PI/2; | |
cairo_set_source_rgba(cr, 1., 1., 1., 1.); | |
cairo_paint(cr); | |
cairo_set_source_rgba(cr, 0., 0., 0., 1.); | |
cairo_set_line_width (cr, 10.); | |
cairo_arc (cr, gWidth/2., gHeight/2., 100., angle, angle + M_PI/4); | |
cairo_stroke (cr); | |
cairo_destroy(cr); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment