Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
colxlate.c File Reference

API colorprocs.h. More...

#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <common/arith.h>
#include <common/color.h>
#include <common/colorprocs.h>
#include <common/colortbl.h>
#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/gv_ctype.h>
#include <cgraph/gv_math.h>
#include <cgraph/strcasecmp.h>
#include <cgraph/unreachable.h>
Include dependency graph for colxlate.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DFLT_SCHEME   "X11/" /* Must have final '/' */
 
#define DFLT_SCHEME_LEN   ((sizeof(DFLT_SCHEME)-1)/sizeof(char))
 
#define ISNONDFLT(s)   ((s) && *(s) && strncasecmp(DFLT_SCHEME, s, DFLT_SCHEME_LEN-1))
 

Functions

static void hsv2rgb (double h, double s, double v, double *r, double *g, double *b)
 
static void rgb2hsv (double r, double g, double b, double *h, double *s, double *v)
 
static int colorcmpf (const void *p0, const void *p1)
 
char * canontoken (char *str)
 
static char * fullColor (agxbuf *xb, const char *prefix, const char *str)
 
static char * resolveColor (char *str)
 
int colorxlate (char *str, gvcolor_t *color, color_type_t target_type)
 
char * setColorScheme (const char *s)
 

Variables

static char * colorscheme
 

Macro Definition Documentation

◆ DFLT_SCHEME

#define DFLT_SCHEME   "X11/" /* Must have final '/' */

Definition at line 181 of file colxlate.c.

◆ DFLT_SCHEME_LEN

#define DFLT_SCHEME_LEN   ((sizeof(DFLT_SCHEME)-1)/sizeof(char))

Definition at line 182 of file colxlate.c.

◆ ISNONDFLT

#define ISNONDFLT (   s)    ((s) && *(s) && strncasecmp(DFLT_SCHEME, s, DFLT_SCHEME_LEN-1))

Definition at line 183 of file colxlate.c.

Function Documentation

◆ canontoken()

char * canontoken ( char *  str)

Definition at line 129 of file colxlate.c.

References agxbdisown(), agxbputc(), canon(), gv_tolower(), and str.

Referenced by gvrender_resolve_color().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ colorcmpf()

static int colorcmpf ( const void *  p0,
const void *  p1 
)
static

Definition at line 124 of file colxlate.c.

◆ colorxlate()

int colorxlate ( char *  str,
gvcolor_t color,
color_type_t  target_type 
)

Definition at line 217 of file colxlate.c.

References A, agxbfree(), agxbputc(), agxbuse(), B, canon(), color(), COLOR_INDEX, color_lib, COLOR_MALLOC_FAIL, COLOR_OK, COLOR_STRING, COLOR_UNKNOWN, colorcmpf(), free(), G, gv_isdigit(), hsv2rgb(), HSVA_DOUBLE, last, NULL, resolveColor(), rgb2hsv(), RGBA_BYTE, RGBA_DOUBLE, RGBA_WORD, agxbuf::s, S, str, agxbuf::u, UNREACHABLE, and V.

Here is the call graph for this function:

◆ fullColor()

static char * fullColor ( agxbuf xb,
const char *  prefix,
const char *  str 
)
static

Definition at line 144 of file colxlate.c.

References agxbprint(), agxbuse(), prefix, and str.

Referenced by resolveColor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hsv2rgb()

static void hsv2rgb ( double  h,
double  s,
double  v,
double *  r,
double *  g,
double *  b 
)
static

Definition at line 35 of file colxlate.c.

References UNREACHABLE.

Referenced by colorxlate().

Here is the caller graph for this function:

◆ resolveColor()

static char * resolveColor ( char *  str)
static

Definition at line 185 of file colxlate.c.

References agxbfree(), colorscheme, DFLT_SCHEME, DFLT_SCHEME_LEN, fullColor(), ISNONDFLT, on_heap(), and str.

Referenced by colorxlate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgb2hsv()

static void rgb2hsv ( double  r,
double  g,
double  b,
double *  h,
double *  s,
double *  v 
)
static

Definition at line 91 of file colxlate.c.

References is_exactly_equal().

Referenced by colorxlate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setColorScheme()

char * setColorScheme ( const char *  s)

set current color scheme for resolving names

Callers should eventually free the returned pointer from this function.

Parameters
sColor scheme to set
Returns
Previous color scheme

Definition at line 414 of file colxlate.c.

References colorscheme, gv_strdup(), and NULL.

Referenced by emit_begin_node(), emit_clusters(), emit_edge_graphics(), emit_end_node(), emit_page(), and object_color().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ colorscheme

char* colorscheme
static

Definition at line 33 of file colxlate.c.

Referenced by resolveColor(), and setColorScheme().