re-organize PS color selection
Improve settings for PS image Improve error messages
This commit is contained in:
parent
67b84f3d2d
commit
cb4eeb44ee
|
|
@ -1,11 +1,12 @@
|
|||
* test de titré
|
||||
.control
|
||||
set hcopydevtype = postscript
|
||||
set hcopypscolor=1
|
||||
set hcopyscale=0.5
|
||||
set hcopypscolor=25
|
||||
set hcopypstxcolor=21
|
||||
set hcopyscale=1
|
||||
set color2=rgb:F/0/0
|
||||
setcs hcopyfont=Arial
|
||||
set hcopyfontsize=14
|
||||
set hcopyfontsize=18
|
||||
|
||||
let x = vector(5)
|
||||
let y = exp(x)
|
||||
|
|
@ -17,6 +18,8 @@ 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"
|
||||
|
|
@ -32,8 +35,9 @@ plot y vs x xlabel '래도 아프지 않아요' ylabel '私はガラスを食べ
|
|||
* 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
|
||||
hardcopy plot_5.ps y vs x xlabel 'Labellisé X' ylabel 'Labellisé Y' title 'Titré Äü @µ€~'
|
||||
shell Start /B plot_5.ps
|
||||
|
||||
echo 나는 유리를 먹을 수 있어요. 그래도 아프지 않아요
|
||||
echo 私はガラスを食べられます。それは私を傷つけません
|
||||
echo 我能吞下玻璃而不伤身体
|
||||
|
|
|
|||
|
|
@ -40,6 +40,36 @@ Author: 1988 Jeffrey M. Hsu
|
|||
#define FONTWIDTH 6 /* printer default fontwidth */
|
||||
#define FONTHEIGHT 14 /* printer default fontheight */
|
||||
|
||||
|
||||
typedef struct {
|
||||
int red, green, blue;
|
||||
} COLOR;
|
||||
|
||||
/* duplicated colors from src/frontend/plotting/x11.c in rgb-style */
|
||||
static const COLOR colors[] = {{ 0, 0, 0}, /*0: black */
|
||||
{255, 255, 255}, /*1: white */
|
||||
{255, 0, 0}, /*2: red */
|
||||
{ 0, 0, 255}, /*3: blue */
|
||||
{255, 165, 0}, /*4: orange */
|
||||
{ 0, 255, 0}, /*5: green */
|
||||
{255, 192, 203}, /*6: pink */
|
||||
{165, 42, 42}, /*7: brown */
|
||||
{240, 230, 140}, /*8: khaki */
|
||||
{221, 160, 221}, /*9: plum */
|
||||
{218, 112, 214}, /*10: orchid */
|
||||
{238, 130, 238}, /*11: violet */
|
||||
{176, 48, 96}, /*12: maroon */
|
||||
{ 64, 224, 208}, /*13: turqoise */
|
||||
{160, 82, 45}, /*14: sienna */
|
||||
{255, 127, 80}, /*15: coral */
|
||||
{ 0, 255, 255}, /*16: cyan */
|
||||
{255, 0, 255}, /*17: magenta */
|
||||
{255, 215, 0}, /*18: gold */
|
||||
{255, 255, 0}, /*19: yello */
|
||||
{ 96, 96, 96}, /*20: gray for smith grid */
|
||||
{150, 150, 150}, /*21: gray for smith grid */
|
||||
{128, 128, 128}}; /*22: gray for normal grid */
|
||||
|
||||
typedef struct {
|
||||
int lastlinestyle, lastcolor; /* initial invalid value */
|
||||
int lastx, lasty, linecount;
|
||||
|
|
@ -73,6 +103,7 @@ static int ytadj; /* text adjustment y */
|
|||
static int hcopygraphid;
|
||||
static double linewidth;
|
||||
static double gridlinewidth;
|
||||
static int maxcolor = 2;
|
||||
|
||||
void PS_LinestyleColor(int linestyleid, int colorid);
|
||||
void PS_SelectColor(int colorid);
|
||||
|
|
@ -85,6 +116,8 @@ int PS_Init(void)
|
|||
{
|
||||
char pswidth[30], psheight[30];
|
||||
|
||||
maxcolor = NUMELEMS(colors);
|
||||
|
||||
if (!cp_getvar("hcopyscale", CP_STRING, psscale, sizeof(psscale))) {
|
||||
scale = 1.0;
|
||||
} else {
|
||||
|
|
@ -100,12 +133,26 @@ int PS_Init(void)
|
|||
dispdev->numcolors = 2;
|
||||
|
||||
} else {
|
||||
/* get backgroung color and set plot to color */
|
||||
/* get text color and set plot to color */
|
||||
colorflag = 1;
|
||||
dispdev->numcolors = 21; /* don't know what the maximum should be */
|
||||
dispdev->numcolors = maxcolor;
|
||||
cp_getvar("hcopypstxcolor", CP_NUM, &settxcolor, 0);
|
||||
}
|
||||
|
||||
if (settxcolor > maxcolor || settxcolor < 0) {
|
||||
fprintf(stderr, "Bad PS text color selection %d\n", settxcolor);
|
||||
fprintf(stderr, " Maximum for hcopypstxcolor is %d\n", maxcolor - 1);
|
||||
colorflag = 0;
|
||||
dispdev->numcolors = 2;
|
||||
}
|
||||
|
||||
if (setbgcolor > maxcolor || setbgcolor < 0) {
|
||||
fprintf(stderr, "Bad PS background color selection %d\n", setbgcolor);
|
||||
fprintf(stderr, " Maximum for hcopypscolor is %d\n", maxcolor - 1);
|
||||
fprintf(stderr, " Set to 1 (white)\n");
|
||||
setbgcolor = 1;
|
||||
}
|
||||
|
||||
/* plot size */
|
||||
if (!cp_getvar("hcopywidth", CP_STRING, pswidth, sizeof( pswidth))) {
|
||||
dispdev->width = (int)(7.75 * 72.0 * scale); /* (8 1/2 - 3/4) * 72 */
|
||||
|
|
@ -163,7 +210,7 @@ int PS_Init(void)
|
|||
}
|
||||
else {
|
||||
sscanf(psfontsize, "%d", &fontsize);
|
||||
if ((fontsize < 10) || (fontsize > 14))
|
||||
if ((fontsize < 10) || (fontsize > 18))
|
||||
fontsize = 10;
|
||||
fontwidth = (int)(0.5 + 0.6 * fontsize);
|
||||
fontheight = (int)(2.5 + 1.2 * fontsize);
|
||||
|
|
@ -214,13 +261,13 @@ int PS_NewViewport(GRAPH *graph)
|
|||
xoff = (int)(scale * XOFF);
|
||||
yoff = (int)(scale * YOFF);
|
||||
|
||||
x1 = (int)(0.75 * 72);
|
||||
x1 = (int) (0.5 * 72 - fontheight);
|
||||
y1 = x1;
|
||||
x2 = (int)(graph->absolute.width + .75 * 72);
|
||||
x2 = (int)(graph->absolute.width + .5 * 72);
|
||||
y2 = (int)(graph->absolute.height + .75 * 72);
|
||||
/* start file off with a % */
|
||||
fprintf(plotfile, "%%!PS-Adobe-3.0 EPSF-3.0\n");
|
||||
fprintf(plotfile, "%%%%Creator: nutmeg\n");
|
||||
fprintf(plotfile, "%%%%Creator: ngspice\n");
|
||||
fprintf(plotfile, "%%%%BoundingBox: %d %d %d %d\n", x1, y1, x2, y2);
|
||||
|
||||
/* Re-encoding to allow 'extended asccii'
|
||||
|
|
@ -432,31 +479,6 @@ void PS_SelectColor(int colorid) /* should be replaced by PS_DefineCol
|
|||
char rgb[30], s_red[30] = "0x", s_green[30] = "0x", s_blue[30] = "0x";
|
||||
int red = 0, green = 0, blue = 0, maxval = 1;
|
||||
int i;
|
||||
typedef struct { int red, green, blue;} COLOR;
|
||||
/* duplicated colors from src/frontend/plotting/x11.c in rgb-style */
|
||||
const COLOR colors[] = {{ 0, 0, 0}, /*0: black */
|
||||
{255, 255, 255}, /*1: white */
|
||||
{255, 0, 0}, /*2: red */
|
||||
{ 0, 0, 255}, /*3: blue */
|
||||
{255, 165, 0}, /*4: orange */
|
||||
{ 0, 255, 0}, /*5: green */
|
||||
{255, 192, 203}, /*6: pink */
|
||||
{165, 42, 42}, /*7: brown */
|
||||
{240, 230, 140}, /*8: khaki */
|
||||
{221, 160, 221}, /*9: plum */
|
||||
{218, 112, 214}, /*10: orchid */
|
||||
{238, 130, 238}, /*11: violet */
|
||||
{176, 48, 96}, /*12: maroon */
|
||||
{ 64, 224, 208}, /*13: turqoise */
|
||||
{160, 82, 45}, /*14: sienna */
|
||||
{255, 127, 80}, /*15: coral */
|
||||
{ 0, 255, 255}, /*16: cyan */
|
||||
{255, 0, 255}, /*17: magenta */
|
||||
/*{255, 215, 0}, 18: gold */
|
||||
{ 96, 96, 96}, /*18: gray for smith grid */
|
||||
/*{255, 255, 0}, 19: yello */
|
||||
{150, 150, 150}, /*19: gray for smith grid */
|
||||
{128, 128, 128}}; /*20: gray for normal grid */
|
||||
|
||||
/* Extract the rgbcolor, format is: "rgb:<red>/<green>/<blue>" */
|
||||
sprintf(colorN, "color%d", colorid);
|
||||
|
|
@ -478,7 +500,7 @@ void PS_SelectColor(int colorid) /* should be replaced by PS_DefineCol
|
|||
strcpy(pscolor, colorstring);
|
||||
}
|
||||
}
|
||||
if (colorid < 0 || colorid > 20) {
|
||||
if (colorid < 0 || colorid >= maxcolor) {
|
||||
internalerror("bad colorid inside PS_SelectColor");
|
||||
} else if (maxval == 1) { /* colorN is not an rgbstring, use default color */
|
||||
sprintf(colorstring, "%1.3f %1.3f %1.3f", colors[colorid].red/255.0,
|
||||
|
|
|
|||
Loading…
Reference in New Issue