示例#1
0
void
apply_pm3dcolor(struct t_colorspec *tc, const struct termentry *t)
{
    /* V5 - term->linetype(LT_BLACK) would clobber the current	*/
    /* dashtype so instead we use term->set_color(black).	*/
    static t_colorspec black = BLACK_COLORSPEC; 
    double cbval;

    /* Replace colorspec with that of the requested line style */
    struct lp_style_type style;
    if (tc->type == TC_LINESTYLE) {
	lp_use_properties(&style, tc->lt);
	tc = &style.pm3d_color;
    }

    if (tc->type == TC_DEFAULT) {
	t->set_color(&black);
	return;
    }
    if (tc->type == TC_LT) {
	/* Removed Jan 2015 
	if (!monochrome_terminal)
	 */
	    t->set_color(tc);
	return;
    }
    if (tc->type == TC_RGB) {
	/* FIXME: several plausible ways for monochrome terminals to handle color request
	 * (1) Allow all color requests despite the label "monochrome"
	 * (2) Choose any color you want so long as it is black
	 * (3) Convert colors to gray scale (NTSC?)
	 */
	/* Monochrome terminals are still allowed to display rgb variable colors */
	if (monochrome_terminal && tc->value >= 0)
	    t->set_color(&black);
	else
	    t->set_color(tc);
	return;
    }
    if (!is_plot_with_palette()) {
	t->set_color(&black);
	return;
    }
    switch (tc->type) {
	case TC_Z:
		set_color(cb2gray(z2cb(tc->value)));
		break;
	case TC_CB:
		if (CB_AXIS.log)
		    cbval = (tc->value <= 0) ? CB_AXIS.min : (log(tc->value) / CB_AXIS.log_base);
		else
		    cbval = tc->value;
		set_color(cb2gray(cbval));
		break;
	case TC_FRAC:
		set_color(sm_palette.positive == SMPAL_POSITIVE ?  tc->value : 1-tc->value);
		break;
    }
}
示例#2
0
void
apply_pm3dcolor(struct t_colorspec *tc, const struct termentry *t)
{

    /* Replace colorspec with that of the requested line style */
    struct lp_style_type style;
    if (tc->type == TC_LINESTYLE) {
	lp_use_properties(&style, tc->lt);
	(*t->linetype)(style.l_type);
	tc = &style.pm3d_color;
    }

    if (tc->type == TC_DEFAULT) {
	(*t->linetype)(LT_BLACK);
	return;
    }
    if (tc->type == TC_LT) {
	if (t->set_color)
	    t->set_color(tc);
	else
	    (*t->linetype)(tc->lt);
	return;
    }
    if (tc->type == TC_RGB && t->set_color) {
	t->set_color(tc);
	return;
    }
    if (!is_plot_with_palette() || !t->set_color) {
	(*t->linetype)(LT_BLACK);
	return;
    }
    switch (tc->type) {
	case TC_Z:    set_color(cb2gray(z2cb(tc->value))); break;
	case TC_CB:   set_color(cb2gray(tc->value));       break;
	case TC_FRAC: set_color(sm_palette.positive == SMPAL_POSITIVE ?
				tc->value : 1-tc->value);
		      break;
    }
}