/* gcc -o psycho psycho.c -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXext -lXxf86vm -lm */ #include #include #include #include #include #define GAMMA_COMPONENTS 3 #define GAMMA_RESOLUTION 256 /* * Ben Winslow - 9/28/2001 * * Modified Fri Sep 28 20:16:59 CDT 2001 by Zinx Verituse - Psychadelic color cycling :P */ Display *dpy; unsigned short ramp_in[GAMMA_COMPONENTS][GAMMA_RESOLUTION]; void sighand(int sig) { XF86VidModeSetGammaRamp(dpy, DefaultScreen(dpy), GAMMA_RESOLUTION, ramp_in[0], ramp_in[1], ramp_in[2]); exit(sig); } int main(int argc, char *argv[]) { unsigned short ramp_out[GAMMA_COMPONENTS][GAMMA_RESOLUTION]; int x, y; int n[GAMMA_COMPONENTS], nd[GAMMA_COMPONENTS], nt[GAMMA_COMPONENTS]; dpy = XOpenDisplay(NULL); if (XF86VidModeGetGammaRamp(dpy, DefaultScreen(dpy), GAMMA_RESOLUTION, ramp_in[0], ramp_in[1], ramp_in[2]) == False) return 1; signal(SIGSEGV, sighand); signal(SIGTERM, sighand); signal(SIGINT, sighand); signal(SIGHUP, sighand); signal(SIGALRM, sighand); srand(time(NULL)+getpid()); for (x = 0; x < GAMMA_COMPONENTS; x++) { n[x] = rand()%360; nd[x] = (rand()&1)?-1:1; nt[x] = rand()%720 + 100; } for (;;) { for (x = 0; x < GAMMA_COMPONENTS; x++) { for (y = 0; y < GAMMA_RESOLUTION; y++) { double t = (double)(y-GAMMA_RESOLUTION/2) / (double)(GAMMA_RESOLUTION/2); // t = cos((t*M_PI) + ((n[x]*M_PI)/180.0)); // t = cos((t*(M_PI+M_PI_2)) + ((n[x]*M_PI)/180.0)); t = cos((t*M_PI*0.8) + ((n[x]*M_PI)/180.0)); ramp_out[x][y] = (t * 32767) + 32767; } if (--nt[x] < 0) { nd[x] = -nd[x]; nt[x] = rand()%720 + 100; } n[x] += nd[x]; if (n[x] < 0) n[x] += 360; else if (n[x] >= 360) n[x] -= 360; } if (XF86VidModeSetGammaRamp(dpy, DefaultScreen(dpy), GAMMA_RESOLUTION, ramp_out[0], ramp_out[1], ramp_out[2]) == False) return 1; usleep(10000); } /* Not reached */ }