-
Notifications
You must be signed in to change notification settings - Fork 1
/
s.c
105 lines (67 loc) · 2.24 KB
/
s.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
create enum from array of strings
lazy and naive method
gcc s.c -Wall
./a.out
typedef enum {RainbowHSV , Linas , Linas2 , RainbowFractalizer , OrangeBlueFractalizer , RainbowHSP , HSP , Magma , Cubehelix , CoolWarm , Green , Linear , Quadratic , Cubic , Sqrt , Gamma , LSine , SineExp , Sine , Smooth } ColorTransferFunctionType;
typedef enum {no = 0, steps = 1, tubes = 2} GradientJoiningType;
titles = "RainbowHSV Linas Linas2 RainbowFractalizer OrangeBlueFractalizer RainbowHSP HSP Magma Cubehelix CoolWarm Green Linear Quadratic Cubic Sqrt Gamma LSine SineExp Sine Smooth "
sGradientJoiningType = "no steps tubes "
*/
#include <stdio.h>
#include <stdlib.h> // malloc
#include <string.h> // strcat
const char *titles[] = {
/* multihue */ "RainbowHSV","Linas","Linas2","RainbowFractalizer", "OrangeBlueFractalizer", "RainbowHSP", "HSP", "Magma","Cubehelix", "CoolWarm",
/* single hue */ "Green",
/* gray */ "Linear","Quadratic","Cubic","Sqrt", "Gamma", "LSine", "SineExp", "Sine" , "Smooth"};
const char * sGradientJoiningType[] = {"no" , "steps" , "tubes"};
// print enum type
void PrintEnums(){
// titles
int i = 0;
int iMax = sizeof(titles)/ sizeof(titles[0]);
printf("typedef enum {");
for (i =0; i< iMax; ++i){
printf("%s ", titles[i]);
if ( i<iMax-1) printf(", ");
}
printf("} ColorTransferFunctionType; \n\n");
// sGradientJoiningType
i = 0;
iMax = sizeof(sGradientJoiningType)/ sizeof(sGradientJoiningType[0]);
printf("typedef enum {");
for (i =0; i< iMax; ++i){
printf("%s = %d", sGradientJoiningType[i], i);
if ( i<iMax-1) printf(", ");
}
printf("} GradientJoiningType;\n\n\n\n");
}
/*
gnuplot
titles = "RainbowHSV Linas GraySineStep"
*/
// print gnuplot array for use in plot.gp
void PrintGnuplot(){
// titles
int i = 0;
int iMax = sizeof(titles)/ sizeof(titles[0]);
printf("titles = \"");
for (i =0; i< iMax; ++i){
printf("%s ", titles[i]);
}
printf("\"\n\n");
// sGradientJoiningType
i = 0;
iMax = sizeof(sGradientJoiningType)/ sizeof(sGradientJoiningType[0]);
printf("sGradientJoiningType = \"");
for (i =0; i< iMax; ++i){
printf("%s ", sGradientJoiningType[i]);
}
printf("\"\n\n");
}
int main (){
PrintEnums();
PrintGnuplot();
return 0;
}