00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _COLORMAP_H
00010 #define _COLORMAP_H
00011
00012
00013 static void colormap1(double x, int *r, int *g, int *b)
00014 {
00015 int i; double alpha;
00016 #define map1n 6
00017 static double xtick[map1n]={0,0.125,0.375,0.625,0.875,1};
00018 static double ctick[map1n][3]={ {0,0,0.9}, {0,0,1}, {0,1,1}, {1,1,0},
00019 {1,0,0}, {0.9,0,0}};
00020
00021
00022
00023 double c[3];
00024
00025 if (x<xtick[0]) {
00026 c[0]=ctick[0][0];
00027 c[1]=ctick[0][1];
00028 c[2]=ctick[0][2];
00029 *r=(int)floor(c[0]*255);
00030 *g=(int)floor(c[1]*255);
00031 *b=(int)floor(c[2]*255);
00032
00033 return;
00034 };
00035 if (x>=xtick[map1n-1]) {
00036 c[0]=ctick[map1n-1][0];
00037 c[1]=ctick[map1n-1][1];
00038 c[2]=ctick[map1n-1][2];
00039 *r=(int)floor(c[0]*255);
00040 *g=(int)floor(c[1]*255);
00041 *b=(int)floor(c[2]*255);
00042
00043 return;
00044 };
00045 for(i=1;i<=map1n-1;i++) {
00046 if(x<xtick[i])
00047 {
00048 alpha=(x-xtick[i-1])/(xtick[i]-xtick[i-1]);
00049 c[0]=(1-alpha)*ctick[i-1][0]+alpha*ctick[i][0];
00050 c[1]=(1-alpha)*ctick[i-1][1]+alpha*ctick[i][1];
00051 c[2]=(1-alpha)*ctick[i-1][2]+alpha*ctick[i][2];
00052 *r=(int)floor(c[0]*255);
00053 *g=(int)floor(c[1]*255);
00054 *b=(int)floor(c[2]*255);
00055
00056 return;
00057 }
00058 }
00059 }
00060
00061 static void colormap2(double x, int *r, int *g, int *b)
00062 {
00063 int i; double alpha;
00064 #define map2n 5
00065 static double xtick[map2n]={0,0.25,0.5,0.75,1};
00066 static double ctick[map2n][3]={ {0,0.2,1}, {0.25,0.2,0.75}, {0.5,0.2,0.5},
00067 {0.75,0.2,0.25}, {1,0.2,0}};
00068
00069
00070
00071
00072 double c[3];
00073 if (x<xtick[0]) {
00074 c[0]=ctick[0][0];
00075 c[1]=ctick[0][1];
00076 c[2]=ctick[0][2];
00077 *r=(int)floor(c[0]*255);
00078 *g=(int)floor(c[1]*255);
00079 *b=(int)floor(c[2]*255);
00080
00081 return;
00082 };
00083 if (x>=xtick[map2n-1]) {
00084 c[0]=ctick[map2n-1][0];
00085 c[1]=ctick[map2n-1][1];
00086 c[2]=ctick[map2n-1][2];
00087 *r=(int)floor(c[0]*255);
00088 *g=(int)floor(c[1]*255);
00089 *b=(int)floor(c[2]*255);
00090
00091 return;
00092 };
00093 for(i=1;i<=map2n-1;i++) {
00094 if(x<xtick[i])
00095 {
00096 alpha=(x-xtick[i-1])/(xtick[i]-xtick[i-1]);
00097 c[0]=(1-alpha)*ctick[i-1][0]+alpha*ctick[i][0];
00098 c[1]=(1-alpha)*ctick[i-1][1]+alpha*ctick[i][1];
00099 c[2]=(1-alpha)*ctick[i-1][2]+alpha*ctick[i][2];
00100 *r=(int)floor(c[0]*255);
00101 *g=(int)floor(c[1]*255);
00102 *b=(int)floor(c[2]*255);
00103
00104 return;
00105 }
00106 }
00107 }
00108
00109 #endif // _COLORMAP_H
00110