File: flimapnextcolor.c

package info (click to toggle)
xplot 1.19-9.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: ansic: 1,264; sh: 359; makefile: 86
file content (32 lines) | stat: -rw-r--r-- 665 bytes parent folder | download | duplicates (8)
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

#include <fli.h>

int fli_map_next_color (int r, int g, int b)
{
    int
	red, green, blue;
    register int
	index;

    /* loop through colormap to find next free color */
    for (index = 0; index <= FL_FREE_COL16; index++)
    {
	/* obtain RGB components */ 
	fl_getmcolor (index, &red, &green, &blue);

	/* if equal, don't redefine */ 
	if (red == r && green == g && blue == b)
	    return (index);

	/* if unused: redefine the slot, if in free colors range */ 
	if (index >= FL_FREE_COL1 &&
	    red == 255 && green == 255 && blue == 255)
	{
	    fl_mapcolor (index, r, g, b);
	    return (index);
	}
    }

    /* no more empty slots */ 
    return (-1);
}