File: initlgluts.c

package info (click to toggle)
pgplot5 5.2-13
  • links: PTS
  • area: non-free
  • in suites: potato
  • size: 6,280 kB
  • ctags: 5,903
  • sloc: fortran: 37,938; ansic: 18,809; sh: 1,147; objc: 532; makefile: 363; perl: 234; pascal: 233; tcl: 178; awk: 51; csh: 25
file content (78 lines) | stat: -rw-r--r-- 2,095 bytes parent folder | download | duplicates (15)
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
/* The initluts routine initializes the LUTs for the line graphics window */

/* Sam Southard, Jr. */
/* Created: 13-Mar-1991 (from figdisp/initluts) */
/* Modification History: */
/* 15-Aug-1991	SNS/CIT	No longer contains hooks for xvideo */
/*  8-Oct-1991	SNS/CIT	Globals now in globals.h */
/* 14-Feb-1992	SNS/CIT	Now deals with grey scale and read only visuals */

/* The X Window include files */
#include <X11/Xlib.h>

/* The program include files */
#include "figdisp.h"
#include "globals.h"

static unsigned short pgcolors[LG_COLORS][3]= {
	    0,	    0,	    0,
	65535,	65535,	65535,
	65535,	    0,	    0,
	    0,	65535,	    0,
	    0,	    0,	65535,
	    0,	65535,	65535,
	65535,	    0,	65535,
	65535,	65535,	    0,
	65535,	32768,	    0,
	32768,	65535,	    0,
	    0,	65535,	32768,
	    0,	32768,	65535,
	32768,	    0,	65535,
	65535,	    0,	32768,
	21845,	21845,	21845,
	43690,	43690,	43690	};

void initlgluts()
{
	XColor color;			/* The color table entry */
	int i;				/* silly loop variables */

	/* If we're dealing with 2 colors, return right away, since it's */
	/* already done. */
	if (lg.colors == 2) return;

	color.flags=DoRed | DoGreen | DoBlue;

	/* PGPLOT defines the first 16 colors */
	for (i=0 ; i < lg.colors && i < 16 ; ++i)
	{
		if (lg.bw) color.red=color.green=color.blue=
			0.30*pgcolors[i][0]+0.59*pgcolors[i][1]+
			0.11*pgcolors[i][2];
		else {
			color.red=pgcolors[i][0];
			color.green=pgcolors[i][1];
			color.blue=pgcolors[i][2];
		}
		color.pixel=lg.pix[i];
		if (lg.ro) {
			XAllocColor(display, linecmap, &color);
			lg.pix[i]=color.pixel;
		}
		else XStoreColor(display, linecmap, &color);
	}

	/* PGPLOT doesn't define these, but I will.  It's a linear greyscale */
	/* with black at 15 (although 15 is used by another color, since we */
	/* already have a BlackPixel) and white at lg.colors-1. */
	for ( ; i < lg.colors ; ++i)
	{
		color.red=color.green=color.blue=
			((double)(i-15)/(lg.colors-16))*65535;
		color.pixel=lg.pix[i];
		if (lg.ro) XAllocColor(display, linecmap, &color);
		else XStoreColor(display, linecmap, &color);
	}
		
	return;
}