7
/*----------------------------------------*/
8
/* POSTSCRIPT specific section */
9
/*----------------------------------------*/
20
static HTMLrecord html[5]; /* POSTSCRIPT-specifics*/
21
static int open_TR = FALSE;
22
static int open_TABLE = FALSE;
25
static void Gray(RGB *rgb, double gray) {
31
static void Rgb(RGB *rgb, double r, double g, double b) {
37
static void Code2Color(char code, RGB *rgb) {
39
case 'W': Gray(rgb, 1.0); break;
41
case '5': Gray(rgb, 0.8);
44
case '6': Gray(rgb, 0.6);
47
case '7': Gray(rgb, 0.4);
50
case '8': Gray(rgb, 0.2);
52
case 'B': Gray(rgb, 0.0); break;
53
case 'R': Rgb(rgb, 1.0, 0.0, 0.0); break;
54
case 'G': Rgb(rgb, 0.0, 1.0, 0.0); break;
55
case 'L': Rgb(rgb, 0.0, 0.0, 1.0); break;
56
case 'Y': Rgb(rgb, 1.0, 1.0, 0.0); break;
57
case 'M': Rgb(rgb, 1.0, 0.0, 1.0); break;
58
case 'C': Rgb(rgb, 0.0, 1.0, 1.0); break;
62
static void menu_HTML(HTMLrecord *html, BOOL *lc, char *txt, char *parstring)
68
printf("\n----------------------------------------------------------------\n"
69
"Enter the text attributes for printing of **>%s<** residues:\n", txt);
70
printf("First choose the color/gray-value of the letter **>background<**\n"
71
"Different letters specify different colors,\n"
72
"(B) Black, (W) white (1,2,3,4) 4 different gray values, 4 is darkest\n"
73
"(R) Red, (G) Green, (L) Blue, (Y) Yellow, (M) Magenta, (C) Cyan\n\n"
74
"choose from BWRGLYMC1234 ( * %c * ) : ", parstring[0]);
75
Fgets(instring, 41, stdin);
78
if (*instring == '\0')
83
if (strchr( "BWRGLYMC1234", code) == NULL)
86
Code2Color(code, &(html->bg));
89
printf("\n\nNow choose the color/gray-value of the letter **>foreground<**\n"
90
"lowercase choices mean lowercase letters in the sequence:\n"
91
"(B,b) black (W,w) white (1,2,3,4) 4 different gray values, 4 is darkest\n"
92
"(R,r) red (G,g) green (5,6,7,8) same, but lowercase letters\n"
93
"(L,l) blue (Y,y) yellow (M,m) magenta (C,c) cyan\n\n"
94
"choose from BbWwRrGgLlYyMmCc12345678 ( * %c * ) : ", parstring[1]);
95
Fgets(instring, 41, stdin);
98
if (*instring == '\0')
102
if (strchr("BbWwRrGgLlYyMmCc12345678", code) == NULL)
109
case '4' : *lc = FALSE;
114
case '8' : *lc = TRUE;
116
default : *lc = islower(code);
120
code = toupper(code);
122
Code2Color(code, &(html->fg));
125
static void Ask(void)
130
printf("----------------------------------------------------------------\n");
132
Fgets(parstring, 6, parfile);
134
menu_HTML(&html[0], &lc[0], "different", parstring);
135
Fgets(parstring, 6, parfile);
137
menu_HTML(&html[1], &lc[1], "identical", parstring);
138
Fgets(parstring, 6, parfile);
141
menu_HTML(&html[2], &lc[2], "similar", parstring);
146
Fgets(parstring, 6, parfile);
149
menu_HTML(&html[3], &lc[3], "conserved", parstring);
154
Gray(&html[4].bg, 1.0);
155
Gray(&html[4].fg, 0.0);
160
printf("filename for HTML-output : ");
162
} while (*outname == '\0');
165
#define col255(cv) ((int)(255.0*(cv)))
167
static void ColWrite(RGB *rgb) {
168
fprintf(outfile.f, "\"#%02X%02X%02X\"", col255(rgb->r), col255(rgb->g), col255(rgb->b));
171
static int coleq(RGB *c1, RGB *c2) {
172
return (col255(c1->r) == col255(c2->r))
173
&& (col255(c1->g) == col255(c2->g))
174
&& (col255(c1->b) == col255(c2->b));
177
#define isBG(rgb) coleq((rgb),&html[4].bg)
178
#define isTC(rgb) coleq((rgb),&html[4].fg)
180
static void StartTR(void) {
182
uwriteln(&outfile, "<tr align=center>");
187
static void CloseTR(void) {
189
uwriteln(&outfile, "</tr>");
194
static void StartTable(void) {
195
uwriteln(&outfile, "<table border=0 cellspacing=0 CELLPADDING=0>");
200
static void CloseTable(void) {
203
uwriteln(&outfile, "</table>");
208
static void dv_Init(double *xpos, double *ypos) {
216
*ypos = dev_maxy - dev_ysize;
217
lines_per_page = (int)((dev_maxy - dev_miny) / dev_ysize);
218
assert( outopen(&outfile, outname) != NULL);
220
uwriteln(&outfile, "<html>");
221
uwriteln(&outfile, "<head>");
222
uwriteln(&outfile, "<title>BoxShade " BOXSHADE_ver " Output</title>");
223
uwriteln(&outfile, "</head>");
224
fprintf(outfile.f, "<body BGCOLOR=");
225
ColWrite(&html[4].bg);
226
fprintf(outfile.f, " TEXT=");
227
ColWrite(&html[4].fg);
228
uwriteln(&outfile, ">");
231
static void Setcolor(int colno) {
235
static void StrgChar(int ch, char *s, double *xpos, double *ypos) {
237
if (!open_TABLE) StartTable();
239
fprintf(outfile.f, "<td%s", (s != NULL ? " align=left": "") );
240
if (!isBG(&html[Col].bg)) {
241
fprintf(outfile.f, " BGCOLOR=");
242
ColWrite(&html[Col].bg);
244
fprintf(outfile.f, ">");
245
if (!isTC(&html[Col].fg)) {
246
fprintf(outfile.f, "<FONT COLOR=");
247
ColWrite(&html[Col].fg);
248
fprintf(outfile.f, ">");
252
if (ch != ' ') fprintf(outfile.f, "%c%s", ch, fc);
253
else fprintf(outfile.f, " %s", fc);
256
fprintf(outfile.f, "%s%s ", s, fc);
257
*xpos += strlen(s)*dev_xsize;
259
uwriteln(&outfile, "</TD>");
262
static void Charout(char c, double *xpos, double *ypos) {
263
StrgChar(c, NULL, xpos, ypos);
266
static void Stringout(char *s, double *xpos, double *ypos) {
267
StrgChar('\0', s, xpos, ypos);
270
static void Newline(double *xpos, double *ypos) {
273
uwriteln(&outfile, "<td> </td>");
280
static void Newpage(double *xpos, double *ypos) {
283
*ypos = dev_maxy - dev_ysize;
286
static void dv_Exit(void) {
289
uwriteln(&outfile, "</body>");
290
uwriteln(&outfile, "</html>");
291
if (outfile.f != NULL)
296
GraphicsDevice Html = {