Example #1
0
static int search_col(t_psdata ps, real r, real g, real b)
{
    int  i;
    char buf[12];

    for (i = 0; (i < ps->nrgb); i++)
    {
        if ((ps->rgb[i].r == r) && (ps->rgb[i].g == g) && (ps->rgb[i].b == b))
        {
            return i;
        }
    }

    if (ps->nrgb >= ps->maxrgb)
    {
        ps->maxrgb += 100;
        srenew(ps->rgb, ps->maxrgb);
    }

    sprintf(buf, "C%d", ps->nrgb);
    ps_defcolor(ps, r, g, b, buf);
    fprintf(ps->fp, "/B%d {%s b} bind def\n", ps->nrgb, buf);
    ps->rgb[i].r = r;
    ps->rgb[i].g = g;
    ps->rgb[i].b = b;
    ps->nrgb++;

    return (ps->nrgb-1);
}
Example #2
0
static int search_col(FILE *ps,real r,real g,real b)
{
  int  i;
  
  for(i=0; (i<nrgb); i++)
    if ( (fabs(rgb[i].r-r) < GMX_REAL_EPS) &&
	 (fabs(rgb[i].g-g) < GMX_REAL_EPS) &&
	 (fabs(rgb[i].b-b) < GMX_REAL_EPS))
      return i;
  
  if (nrgb >= maxrgb) 
    {
      maxrgb+=100;
      srenew(rgb,maxrgb);
    }
  
  ps_defcolor(ps,r,g,b,i2a(nrgb));
  fprintf(ps,"/B%d {%s b} bind def\n",nrgb,i2a(nrgb));
  rgb[i].r=r;
  rgb[i].g=g;
  rgb[i].b=b;
  nrgb++;
  
  return nrgb-1;
}