Graphviz 13.0.0~dev.20241220.2304
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 <util/agxbuf.h>
#include <util/alloc.h>
#include <util/gv_ctype.h>
#include <util/gv_math.h>
#include <util/strcasecmp.h>
#include <util/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)
 
static char * fullColor (agxbuf *xb, const char *prefix, const char *str)
 
static char * resolveColor (const char *str)
 
int colorxlate (const 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 169 of file colxlate.c.

◆ DFLT_SCHEME_LEN

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

Definition at line 170 of file colxlate.c.

◆ ISNONDFLT

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

Definition at line 171 of file colxlate.c.

Function Documentation

◆ colorcmpf()

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

Definition at line 124 of file colxlate.c.

◆ colorxlate()

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

Definition at line 203 of file colxlate.c.

References hsvrgbacolor_t::a, A, agxbfree(), agxbputc(), agxbuse(), hsvrgbacolor_t::b, B, canon(), color(), COLOR_INDEX, color_lib, COLOR_MALLOC_FAIL, COLOR_OK, COLOR_STRING, COLOR_UNKNOWN, colorcmpf(), free(), hsvrgbacolor_t::g, G, gv_isdigit(), hsvrgbacolor_t::h, hsv2rgb(), HSVA_DOUBLE, NULL, hsvrgbacolor_t::r, resolveColor(), rgb2hsv(), RGBA_BYTE, RGBA_DOUBLE, RGBA_WORD, hsvrgbacolor_t::s, S, str, UNREACHABLE, hsvrgbacolor_t::v, 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 132 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 ( const char *  str)
static

Definition at line 173 of file colxlate.c.

References agxbfree(), colorscheme, DFLT_SCHEME, DFLT_SCHEME_LEN, fullColor(), ISNONDFLT, NULL, 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 395 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().