Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
gvrender_core_svg.c File Reference
#include "config.h"
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <common/macros.h>
#include <common/const.h>
#include <gvc/gvplugin_render.h>
#include <cgraph/agxbuf.h>
#include <cgraph/unreachable.h>
#include <common/utils.h>
#include <gvc/gvplugin_device.h>
#include <gvc/gvio.h>
#include <gvc/gvcint.h>
#include <cgraph/strcasecmp.h>
Include dependency graph for gvrender_core_svg.c:

Go to the source code of this file.

Macros

#define LOCALNAMEPREFIX   '%'
 
#define EDGEALIGN   0
 

Enumerations

enum  format_type { FORMAT_SVG , FORMAT_SVGZ , FORMAT_SVG_INLINE }
 

Functions

static bool emit_standalone_headers (const GVJ_t *job)
 
static void svg_bzptarray (GVJ_t *job, pointf *A, size_t n)
 
static void svg_print_id_class (GVJ_t *job, char *id, char *idx, char *kind, void *obj)
 
static void svg_print_paint (GVJ_t *job, gvcolor_t color)
 
static void svg_print_gradient_color (GVJ_t *job, gvcolor_t color)
 
static void svg_grstyle (GVJ_t *job, int filled, int gid)
 
static void svg_comment (GVJ_t *job, char *str)
 
static void svg_begin_job (GVJ_t *job)
 
static void svg_begin_graph (GVJ_t *job)
 
static void svg_end_graph (GVJ_t *job)
 
static void svg_begin_layer (GVJ_t *job, char *layername, int layerNum, int numLayers)
 
static void svg_end_layer (GVJ_t *job)
 
static void svg_begin_page (GVJ_t *job)
 
static void svg_end_page (GVJ_t *job)
 
static void svg_begin_cluster (GVJ_t *job)
 
static void svg_end_cluster (GVJ_t *job)
 
static void svg_begin_node (GVJ_t *job)
 
static void svg_end_node (GVJ_t *job)
 
static void svg_begin_edge (GVJ_t *job)
 
static void svg_end_edge (GVJ_t *job)
 
static void svg_begin_anchor (GVJ_t *job, char *href, char *tooltip, char *target, char *id)
 
static void svg_end_anchor (GVJ_t *job)
 
static void svg_textspan (GVJ_t *job, pointf p, textspan_t *span)
 
static void svg_print_stop (GVJ_t *job, double offset, gvcolor_t color)
 
static int svg_gradstyle (GVJ_t *job, pointf *A, size_t n)
 
static int svg_rgradstyle (GVJ_t *job)
 
static void svg_ellipse (GVJ_t *job, pointf *A, int filled)
 
static void svg_bezier (GVJ_t *job, pointf *A, size_t n, int filled)
 
static void svg_polygon (GVJ_t *job, pointf *A, size_t n, int filled)
 
static void svg_polyline (GVJ_t *job, pointf *A, size_t n)
 

Variables

static const char sdasharray [] = "5,2"
 
static const char sdotarray [] = "1,5"
 
static const char transparent [] = "transparent"
 
static const char none [] = "none"
 
static const char black [] = "black"
 
static char * svg_knowncolors []
 
gvrender_engine_t svg_engine
 
gvrender_features_t render_features_svg
 
gvdevice_features_t device_features_svg
 
gvdevice_features_t device_features_svgz
 
gvplugin_installed_t gvrender_svg_types []
 
gvplugin_installed_t gvdevice_svg_types []
 

Macro Definition Documentation

◆ EDGEALIGN

#define EDGEALIGN   0

Definition at line 45 of file gvrender_core_svg.c.

◆ LOCALNAMEPREFIX

#define LOCALNAMEPREFIX   '%'

Definition at line 42 of file gvrender_core_svg.c.

Enumeration Type Documentation

◆ format_type

Enumerator
FORMAT_SVG 
FORMAT_SVGZ 
FORMAT_SVG_INLINE 

Definition at line 48 of file gvrender_core_svg.c.

Function Documentation

◆ emit_standalone_headers()

static bool emit_standalone_headers ( const GVJ_t job)
static

Definition at line 59 of file gvrender_core_svg.c.

References FORMAT_SVG_INLINE, gvplugin_active_render_s::id, and GVJ_s::render.

Referenced by svg_begin_graph(), and svg_begin_job().

Here is the caller graph for this function:

◆ svg_begin_anchor()

static void svg_begin_anchor ( GVJ_t job,
char *  href,
char *  tooltip,
char *  target,
char *  id 
)
static

Definition at line 389 of file gvrender_core_svg.c.

References flags, gvputc(), gvputs(), gvputs_xml(), xml_flags_t::raw, and xml_escape().

Here is the call graph for this function:

◆ svg_begin_cluster()

static void svg_begin_cluster ( GVJ_t job)
static

Definition at line 331 of file gvrender_core_svg.c.

References agnameof(), obj_state_s::g, gvputs(), gvputs_xml(), obj_state_s::id, NULL, GVJ_s::obj, obj_state_s::sg, svg_print_id_class(), and obj_state_s::u.

Here is the call graph for this function:

◆ svg_begin_edge()

static void svg_begin_edge ( GVJ_t job)
static

Definition at line 368 of file gvrender_core_svg.c.

References obj_state_s::e, free(), gvputs(), gvputs_xml(), obj_state_s::id, NULL, GVJ_s::obj, strdup_and_subst_obj(), svg_print_id_class(), and obj_state_s::u.

Here is the call graph for this function:

◆ svg_begin_graph()

static void svg_begin_graph ( GVJ_t job)
static

Definition at line 244 of file gvrender_core_svg.c.

References agnameof(), GVJ_s::canvasBox, emit_standalone_headers(), obj_state_s::g, gvprintf(), gvputs(), gvputs_xml(), GVJ_s::height, boxf::LL, LOCALNAMEPREFIX, GVJ_s::obj, GVJ_s::pagesArraySize, obj_state_s::u, boxf::UR, GVJ_s::width, point::x, pointf_s::x, point::y, and pointf_s::y.

Here is the call graph for this function:

◆ svg_begin_job()

static void svg_begin_job ( GVJ_t job)
static

Definition at line 220 of file gvrender_core_svg.c.

References agget(), GVJ_s::common, emit_standalone_headers(), GVC_s::g, GVJ_s::gvc, gvputs(), gvputs_xml(), and GVCOMMON_s::info.

Here is the call graph for this function:

◆ svg_begin_layer()

static void svg_begin_layer ( GVJ_t job,
char *  layername,
int  layerNum,
int  numLayers 
)
static

Definition at line 282 of file gvrender_core_svg.c.

References obj_state_s::g, gvputs(), NULL, GVJ_s::obj, svg_print_id_class(), and obj_state_s::u.

Here is the call graph for this function:

◆ svg_begin_node()

static void svg_begin_node ( GVJ_t job)
static

Definition at line 347 of file gvrender_core_svg.c.

References agnameof(), GVJ_s::gvc, gvputs(), gvputs_xml(), obj_state_s::id, GVC_s::layerIDs, GVJ_s::layerNum, obj_state_s::n, NULL, GVJ_s::obj, svg_print_id_class(), and obj_state_s::u.

Here is the call graph for this function:

◆ svg_begin_page()

static void svg_begin_page ( GVJ_t job)
static

Definition at line 303 of file gvrender_core_svg.c.

References agnameof(), obj_state_s::g, gvprintdouble(), gvprintf(), gvputc(), gvputs(), gvputs_xml(), obj_state_s::id, LOCALNAMEPREFIX, NULL, GVJ_s::obj, GVJ_s::rotation, GVJ_s::scale, svg_print_id_class(), GVJ_s::translation, obj_state_s::u, pointf_s::x, and pointf_s::y.

Here is the call graph for this function:

◆ svg_bezier()

static void svg_bezier ( GVJ_t job,
pointf A,
size_t  n,
int  filled 
)
static

Definition at line 658 of file gvrender_core_svg.c.

References A, GRADIENT, gvputs(), gvputs_xml(), obj_state_s::id, obj_state_s::labeledgealigned, GVJ_s::obj, RGRADIENT, svg_bzptarray(), svg_gradstyle(), svg_grstyle(), and svg_rgradstyle().

Here is the call graph for this function:

◆ svg_bzptarray()

static void svg_bzptarray ( GVJ_t job,
pointf A,
size_t  n 
)
static

Definition at line 63 of file gvrender_core_svg.c.

References A, gvprintdouble(), gvputc(), gvwrite(), and SIZE_MAX.

Referenced by svg_bezier().

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

◆ svg_comment()

static void svg_comment ( GVJ_t job,
char *  str 
)
static

Definition at line 213 of file gvrender_core_svg.c.

References gvputs(), gvputs_xml(), and str.

Here is the call graph for this function:

◆ svg_ellipse()

static void svg_ellipse ( GVJ_t job,
pointf A,
int  filled 
)
static

Definition at line 635 of file gvrender_core_svg.c.

References A, GRADIENT, gvprintdouble(), gvputs(), RGRADIENT, svg_gradstyle(), svg_grstyle(), and svg_rgradstyle().

Here is the call graph for this function:

◆ svg_end_anchor()

static void svg_end_anchor ( GVJ_t job)
static

Definition at line 421 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_cluster()

static void svg_end_cluster ( GVJ_t job)
static

Definition at line 342 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_edge()

static void svg_end_edge ( GVJ_t job)
static

Definition at line 383 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_graph()

static void svg_end_graph ( GVJ_t job)
static

Definition at line 277 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_layer()

static void svg_end_layer ( GVJ_t job)
static

Definition at line 294 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_node()

static void svg_end_node ( GVJ_t job)
static

Definition at line 363 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_end_page()

static void svg_end_page ( GVJ_t job)
static

Definition at line 326 of file gvrender_core_svg.c.

References gvputs().

Here is the call graph for this function:

◆ svg_gradstyle()

static int svg_gradstyle ( GVJ_t job,
pointf A,
size_t  n 
)
static

Definition at line 568 of file gvrender_core_svg.c.

References A, obj_state_s::fillcolor, G, get_gradient_points(), obj_state_s::gradient_angle, obj_state_s::gradient_frac, gvprintdouble(), gvprintf(), gvputc(), gvputs(), gvputs_xml(), id, obj_state_s::id, M_PI, NULL, GVJ_s::obj, obj_state_s::stopcolor, and svg_print_stop().

Referenced by svg_bezier(), svg_ellipse(), and svg_polygon().

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

◆ svg_grstyle()

static void svg_grstyle ( GVJ_t job,
int  filled,
int  gid 
)
static

Definition at line 163 of file gvrender_core_svg.c.

References obj_state_s::fillcolor, GRADIENT, gvprintdouble(), gvprintf(), gvputc(), gvputs(), gvputs_xml(), obj_state_s::id, NULL, GVJ_s::obj, obj_state_s::pen, PEN_DASHED, PEN_DOTTED, obj_state_s::pencolor, obj_state_s::penwidth, PENWIDTH_NORMAL, color_s::rgba, RGBA_BYTE, RGRADIENT, sdasharray, sdotarray, svg_print_paint(), color_s::type, and color_s::u.

Referenced by svg_bezier(), svg_ellipse(), svg_polygon(), and svg_polyline().

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

◆ svg_polygon()

static void svg_polygon ( GVJ_t job,
pointf A,
size_t  n,
int  filled 
)
static

Definition at line 679 of file gvrender_core_svg.c.

References A, GRADIENT, gvprintdouble(), gvputc(), gvputs(), RGRADIENT, svg_gradstyle(), svg_grstyle(), and svg_rgradstyle().

Here is the call graph for this function:

◆ svg_polyline()

static void svg_polyline ( GVJ_t job,
pointf A,
size_t  n 
)
static

Definition at line 702 of file gvrender_core_svg.c.

References A, gvprintdouble(), gvputc(), gvputs(), and svg_grstyle().

Here is the call graph for this function:

◆ svg_print_gradient_color()

static void svg_print_gradient_color ( GVJ_t job,
gvcolor_t  color 
)
static

Definition at line 145 of file gvrender_core_svg.c.

References black, color(), COLOR_STRING, gvprintf(), gvputs(), RGBA_BYTE, transparent, and UNREACHABLE.

Referenced by svg_print_stop().

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

◆ svg_print_id_class()

static void svg_print_id_class ( GVJ_t job,
char *  id,
char *  idx,
char *  kind,
void *  obj 
)
static

Definition at line 96 of file gvrender_core_svg.c.

References agget(), gvprintf(), gvputc(), gvputs(), gvputs_xml(), kind, and str.

Referenced by svg_begin_cluster(), svg_begin_edge(), svg_begin_layer(), svg_begin_node(), and svg_begin_page().

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

◆ svg_print_paint()

static void svg_print_paint ( GVJ_t job,
gvcolor_t  color 
)
static

Definition at line 117 of file gvrender_core_svg.c.

References color(), COLOR_STRING, gvprintf(), gvputs(), none, RGBA_BYTE, transparent, and UNREACHABLE.

Referenced by svg_grstyle().

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

◆ svg_print_stop()

static void svg_print_stop ( GVJ_t job,
double  offset,
gvcolor_t  color 
)
static

Definition at line 546 of file gvrender_core_svg.c.

References color(), COLOR_STRING, gvprintf(), gvputs(), offset, RGBA_BYTE, svg_print_gradient_color(), and transparent.

Referenced by svg_gradstyle(), and svg_rgradstyle().

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

◆ svg_rgradstyle()

static int svg_rgradstyle ( GVJ_t job)
static

Definition at line 604 of file gvrender_core_svg.c.

References obj_state_s::fillcolor, obj_state_s::gradient_angle, gvprintf(), gvputc(), gvputs(), gvputs_xml(), id, obj_state_s::id, M_PI, NULL, GVJ_s::obj, obj_state_s::stopcolor, and svg_print_stop().

Referenced by svg_bezier(), svg_ellipse(), and svg_polygon().

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

◆ svg_textspan()

Variable Documentation

◆ black

const char black[] = "black"
static

◆ device_features_svg

gvdevice_features_t device_features_svg
Initial value:
= {
{0., 0.},
{0., 0.},
{72., 72.},
}
#define GVDEVICE_DOES_LAYERS
Definition gvcjob.h:88
#define GVDEVICE_DOES_TRUECOLOR
Definition gvcjob.h:90

Definition at line 803 of file gvrender_core_svg.c.

◆ device_features_svgz

gvdevice_features_t device_features_svgz
Initial value:
= {
{0., 0.},
{0., 0.},
{72., 72.},
}
#define GVDEVICE_COMPRESSED_FORMAT
Definition gvcjob.h:92
#define GVDEVICE_BINARY_FORMAT
Definition gvcjob.h:91

Definition at line 810 of file gvrender_core_svg.c.

◆ gvdevice_svg_types

gvplugin_installed_t gvdevice_svg_types[]
Initial value:
= {
{FORMAT_SVG, "svg:svg", 1, NULL, &device_features_svg},
{FORMAT_SVG_INLINE, "svg_inline:svg", 1, NULL, &device_features_svg},
{0, NULL, 0, NULL, NULL}
}
node NULL
Definition grammar.y:149
gvdevice_features_t device_features_svg
@ FORMAT_SVG
@ FORMAT_SVG_INLINE

Definition at line 823 of file gvrender_core_svg.c.

◆ gvrender_svg_types

gvplugin_installed_t gvrender_svg_types[]
Initial value:
= {
{0, NULL, 0, NULL, NULL}
}
gvrender_features_t render_features_svg
gvrender_engine_t svg_engine

Definition at line 817 of file gvrender_core_svg.c.

◆ none

const char none[] = "none"
static

Definition at line 56 of file gvrender_core_svg.c.

Referenced by svg_print_paint(), and SWIG_Py_Void().

◆ render_features_svg

gvrender_features_t render_features_svg
Initial value:
= {
4.,
sizeof(svg_knowncolors) / sizeof(char *),
}
@ RGBA_BYTE
Definition color.h:26
#define GVRENDER_DOES_TOOLTIPS
Definition gvcjob.h:103
#define GVRENDER_DOES_LABELS
Definition gvcjob.h:96
#define GVRENDER_DOES_MAPS
Definition gvcjob.h:97
#define GVRENDER_DOES_TARGETS
Definition gvcjob.h:104
#define GVRENDER_DOES_TRANSFORM
Definition gvcjob.h:95
#define GVRENDER_Y_GOES_DOWN
Definition gvcjob.h:94
static char * svg_knowncolors[]

Definition at line 795 of file gvrender_core_svg.c.

◆ sdasharray

const char sdasharray[] = "5,2"
static

Definition at line 51 of file gvrender_core_svg.c.

Referenced by svg_grstyle().

◆ sdotarray

const char sdotarray[] = "1,5"
static

Definition at line 53 of file gvrender_core_svg.c.

Referenced by svg_grstyle().

◆ svg_engine

gvrender_engine_t svg_engine

Definition at line 762 of file gvrender_core_svg.c.

◆ svg_knowncolors

char* svg_knowncolors[]
static

Definition at line 719 of file gvrender_core_svg.c.

◆ transparent

const char transparent[] = "transparent"
static

Definition at line 55 of file gvrender_core_svg.c.

Referenced by svg_print_gradient_color(), svg_print_paint(), and svg_print_stop().