|
|
1.1 ! root 1: /* Calculates gray scale based on mouse offset from window center */ ! 2: #include <X/Xlib.h> ! 3: ! 4: #ifdef MC68000 ! 5: #include <sys/types.h> ! 6: #endif ! 7: ! 8: #include "shimg.h" ! 9: ! 10: #define MIN(a,b) (((a) < (b)) ? (a) : (b)) ! 11: #define MAX(a,b) (((a) > (b)) ? (a) : (b)) ! 12: ! 13: CalcMap(winfo,cmap,x,y,ncolors,flags,key) ! 14: WindowInfo *winfo; ! 15: Color *cmap; ! 16: int x,y, key; ! 17: int ncolors; ! 18: u_short flags; ! 19: { ! 20: register int intercept,slope,intensity,i; ! 21: ! 22: if(x<0 || y<=0 || x>=winfo->width-2 || y>winfo->height) return; ! 23: ! 24: intercept = (((x<<1) - winfo->width)<<16) / winfo->width; ! 25: slope = ((winfo->height - y)<<16) / y; ! 26: ! 27: for(i=0; i<ncolors; i++) { ! 28: intensity = (slope * i)/(ncolors-1) + intercept; ! 29: intensity = MIN(65535,MAX(intensity,0)); ! 30: if(flags & VOP_Inverse) intensity = 65535 - intensity; ! 31: if(flags & VOP_RGB) ! 32: switch((int)key) { ! 33: case LeftButton: ! 34: cmap[i].red = intensity; break; ! 35: case MiddleButton: ! 36: cmap[i].green = intensity; break; ! 37: case RightButton: ! 38: cmap[i].blue = intensity; break; ! 39: } ! 40: else { ! 41: cmap[i].red = cmap[i].blue = cmap[i].green = intensity; ! 42: } ! 43: } ! 44: return; ! 45: } ! 46: ! 47: initcmap(ncolors,cmap,pixel,nplanes,flags) ! 48: int ncolors, nplanes, pixel; ! 49: Color *cmap; ! 50: unsigned short flags; ! 51: { ! 52: int i; ! 53: ! 54: /* Initialize color map to slope 1, intercept 0 */ ! 55: for (i = 0; i < ncolors; i++) { ! 56: cmap[i].pixel = pixel + i; ! 57: cmap[i].red = cmap[i].green = cmap[i].blue = ! 58: ( (flags & VOP_Inverse) ? (65535 - (i << (16 - nplanes))) : ! 59: (i << (16 - nplanes))); ! 60: } ! 61: return; ! 62: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.