color input for text/grids (color1), background (color0)

and graphs (color2-22) on Windows via
set color2=red
set color2=rgb:ff/0/0
set color2=rgbd:255,0,0
several examples given in the example files
This commit is contained in:
Holger Vogt 2020-01-13 23:11:01 +01:00
parent 86917e3d36
commit 1fda03382e
4 changed files with 129 additions and 8 deletions

View File

@ -1,10 +1,10 @@
* test de titré
.control
set hcopydevtype = postscript
set hcopypscolor=25
set hcopypscolor=18
set hcopypstxcolor=21
set hcopyscale=1
set color2=rgb:F/0/0
set color2=rgb:FF/0/0
setcs hcopyfont=Arial
set hcopyfontsize=18
@ -18,8 +18,6 @@ setcs xfont='Noto Sans Chinese'
set gridwidth=4
set xbrushwidth=1
hardcopy
plot y vs x xlabel 'Labellisé X' ylabel 'Labellisé Y: ÜüÖöÄäÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ' title 'Titré'
plot y vs x xlabel '我能吞下玻璃而不伤身体' ylabel 'Я могу есть стекло, оно мне не вредит' title ' أنا قادر على أكل الزجاج و هذا لا يؤلمني.'
* With Linux the next one requires: export LC_CTYPE ="de_DE.UTF-8"

View File

@ -1,4 +1,4 @@
* test de titré
titré 'test of various color inputs for background, text/grid and graphs 1'
.control
set hcopydevtype = postscript
set hcopypscolor=25

View File

@ -0,0 +1,59 @@
* titré 'test of various color inputs for background, text/grid and graphs 2'
.control
set hcopydevtype = postscript
set hcopypscolor=25
set hcopypstxcolor=21
set hcopyscale=1
*set color2=rgb:F/0/0
setcs hcopyfont=Arial
set hcopyfontsize=18
let x = vector(5)
let y = exp(x)
setcs wfont=Arial
set wfont_size=18
setcs xfont='Noto Sans'
*set xfont_size=18
set gridwidth=4
set xbrushwidth=1
set color0=white
*set color2=brown
set color2=rgbd:255/0/0
plot y vs x xlabel 'Labellisé X' ylabel 'Labellisé Y: ÜüÖöÄäÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ' title 'Titré'
set color0=black
plot y vs x xlabel '我能吞下玻璃而不伤身体' ylabel 'Я могу есть стекло, оно мне не вредит' title ' أنا قادر على أكل الزجاج و هذا لا يؤلمني.'
* With Linux the next one requires: export LC_CTYPE ="de_DE.UTF-8"
*gnuplot test.gn y vs x xlabel 'Labellisé X' ylabel 'tüTÄtö Äü @µ€~' title 'ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ '
set color0=Blue
set color1=Yellow
set color2=rgb:00/FF/00
set gridwidth=1
set xbrushwidth=4
plot y vs x+0.001 xlabel 'Labellisé X' ylabel 'Labellisé Y' title 'Titré 私はガラスを食べられます。それは私を傷つけません' loglog
unset color1
set color0=MediumBlue
set color2=Magenta
plot y vs x+0.001 xlabel 'Labellisé X' title 'Titré' loglog
set color0=GreenYellow
set color2=rgbd:128/128/75
plot y vs x+0.001 xlabel 'Labellisé X' title 'Titré' loglog
set color0=black
set color2=pink
plot y vs x xlabel '래도 아프지 않아요' ylabel '私はガラスを食べられます' title ' أنا قادر على أكل الزجاج و هذا لا يؤلمني.'
* With Linux the next one requires: export LC_CTYPE ="de_DE.UTF-8"
*gnuplot test2.gn y vs x xlabel 'Labellisé X' ylabel 'tüTÄtö Äü @µ€~' title 'ฉันกินกระจกได้ แต่มันไม่ทำให้ฉันเจ็บ '
*hardcopy plot_5.ps y vs x xlabel 'Labellisé X' ylabel 'Labellisé Y' title 'Titré Äü @µ€~'
*shell Start /B plot_5.ps
*shell gv plot_5.ps &
echo 나는 유리를 먹을 수 있어요. 그래도 아프지 않아요
echo 私はガラスを食べられます。それは私を傷つけません
echo 我能吞下玻璃而不伤身体
*quit
.endc

View File

@ -43,7 +43,57 @@ void wincolor_init_hash(COLORREF *ColorTable, int noc)
ColorTable[i] = 0;
}
}
/* evaluate rgb:0/FF/F0 rgb:0/F/0 rgbd:295/0/128 */
static COLORREF get_wincolor_rgb(char *costr)
{
char *tmpstr;
if (ciprefix("rgb:", costr)) {
char *t1, *t2, *t3;
tmpstr = costr + 4;
if (tmpstr) {
t1 = gettok_char(&tmpstr, '/', FALSE, FALSE);
tmpstr++;
t2 = gettok_char(&tmpstr, '/', FALSE, FALSE);
tmpstr++;
t3 = copy(tmpstr);
if (t1 && t2 && t3) {
int c1, c2, c3;
c1 = (int) strtol(t1, NULL, 16);
c2 = (int) strtol(t2, NULL, 16);
c3 = (int) strtol(t3, NULL, 16);
tfree(t1);
tfree(t2);
tfree(t3);
return RGB(c1, c2, c3);
}
}
}
else if (ciprefix("rgbd:", costr)) {
char *t1, *t2, *t3;
tmpstr = costr + 5;
if (tmpstr) {
t1 = gettok_char(&tmpstr, '/', FALSE, FALSE);
tmpstr++;
t2 = gettok_char(&tmpstr, '/', FALSE, FALSE);
tmpstr++;
t3 = copy(tmpstr);
if (t1 && t2 && t3) {
int c1, c2, c3;
c1 = (int) strtol(t1, NULL, 10);
c2 = (int) strtol(t2, NULL, 10);
c3 = (int) strtol(t3, NULL, 10);
tfree(t1);
tfree(t2);
tfree(t3);
return RGB(c1, c2, c3);
}
}
}
fprintf(stderr, "Error: Cannot detect color in string %s, setting Web Green\n", costr);
return RGB(0, 128, 0);
}
/* ColorTable[0]: background, ColorTable[1]: grid, text */
void wincolor_init(COLORREF* ColorTable, int noc)
@ -64,8 +114,9 @@ void wincolor_init(COLORREF* ColorTable, int noc)
if (!cp_getvar(buf, CP_STRING, colorstring, sizeof(colorstring))) {
if (i == 1) {
/* switch the grid and text color depending on background */
int tcolor = GetRValue(ColorTable[0]) + GetGValue(ColorTable[0]) + GetBValue(ColorTable[0]);
if (tcolor > 250) {
int tcolor = GetRValue(ColorTable[0]) +
(int)(1.5 * GetGValue(ColorTable[0])) + GetBValue(ColorTable[0]);
if (tcolor > 360) {
ColorTable[1] = RGB(0, 0, 0);
i++;
bgisblack = FALSE;
@ -84,6 +135,11 @@ void wincolor_init(COLORREF* ColorTable, int noc)
else
(void)strcpy(colorstring, stdcolornames[i]);
}
else if (ciprefix("rgb", colorstring)){
ColorTable[i] = get_wincolor_rgb(colorstring);
i++;
continue;
}
ColorTable[i] = get_wincolor(colorstring, nocolor);
i++;
}
@ -97,7 +153,10 @@ void wincolor_redo(COLORREF* ColorTable, int noc)
int nocolor = NUMELEMS(ctable);
while (i < noc) {
/* when color0 is set to white and color1 is not given, set ColorTable[2] to black */
/* when color0 is set to white and color1 is not given, set text and grid color
as ColorTable[1] to black, when color0 is any other color, select black or
white text and grid color according to a weighted value derived from color0.
This selection is a compromise based on visibility.*/
(void)sprintf(buf, "color%d", i);
if (!cp_getvar(buf, CP_STRING, colorstring, sizeof(colorstring))) {
if (i == 1) {
@ -123,6 +182,11 @@ void wincolor_redo(COLORREF* ColorTable, int noc)
else
(void)strcpy(colorstring, stdcolornames[i]);
}
else if (ciprefix("rgb", colorstring)) {
ColorTable[i] = get_wincolor_rgb(colorstring);
i++;
continue;
}
ColorTable[i] = get_wincolor(colorstring, nocolor);
i++;
}