33#define BEZIERSUBDIVISION 6
57 for (
size_t i = 0; i < n; i++) {
68 unsigned char g,
unsigned char b) {
71 long rd, gd, bd,
dist;
72 long mindist = 3 * 255 * 255;
75 for (c = 0; c < st->
top; c++) {
76 rd = (long)st->
red[c] - r;
77 gd = (long)st->
green[c] - g;
78 bd = (long)st->
blue[c] - b;
79 dist = rd * rd + gd * gd + bd * bd;
99static char *
figcolor[] = {
"black",
"blue",
"green",
"cyan",
"red",
100 "magenta",
"yellow",
"white",
NULL};
107 switch (
color->type) {
123 gvprintf(job,
"%d %d #%02x%02x%02x\n",
166 gvputs(job,
"#FIG 3.2\n");
167 gvprintf(job,
"# Generated by %s version %s (%s)\n",
171 gvputs(job,
"Portrait\n");
184 gvputs(job,
"# end of FIG file\n");
226 int depth = st->
Depth;
236 double height = font_size;
237 const size_t span_length = strlen(span->
str);
238 const double length = 2.0 * font_size / 3.0 * (double)span_length / 2.0;
244 switch (span->
just) {
264 "%d %d %d %d %d %d %.1f %.4f %d %.1f %.1f %.0f %.0f ",
265 object_code, sub_type,
color, depth, pen_style,
font,
266 font_size, angle, font_flags, height,
length, round(p.
x),
280 double thickness = round(obj->
penwidth);
283 int depth = st->
Depth;
285 int area_fill = filled ? 20 : -1;
289 double center_x, center_y;
293 const double start_x = center_x = round(
A[0].x);
294 const double start_y = center_y = round(
A[0].y);
295 const double radius_x = round(
A[1].x -
A[0].x);
296 const double radius_y = round(
A[1].y -
A[0].y);
297 const double end_x = round(
A[1].x);
298 const double end_y = round(
A[1].y);
301 "%d %d %d %.0f %d %d %d %d %d %.3f %d %.4f %.0f %.0f %.0f %.0f "
302 "%.0f %.0f %.0f %.0f\n",
303 object_code, sub_type, line_style, thickness, pen_color,
304 fill_color, depth, pen_style, area_fill, style_val, direction,
305 angle, center_x, center_y, radius_x, radius_y, start_x,
306 start_y, end_x, end_y);
316 double thickness = round(obj->
penwidth);
319 int depth = st->
Depth;
324 int forward_arrow = 0;
325 int backward_arrow = 0;
352 for (
size_t i = 0; i + 3 < n; i += 3) {
354 for (
size_t j = 1; j <= 3; j++) {
365 gvprintf(job,
"%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d\n",
375 style_val, cap_style, forward_arrow, backward_arrow, count);
379 for (
int i = 0; i < count; i++) {
380 gvprintf(job,
" %d", i % (count - 1) ? 1 : 0);
392 double thickness = round(obj->
penwidth);
395 int depth = st->
Depth;
397 int area_fill = filled ? 20 : -1;
402 int forward_arrow = 0;
403 int backward_arrow = 0;
404 const size_t npoints = n + 1;
409 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
410 object_code, sub_type, line_style, thickness, pen_color,
411 fill_color, depth, pen_style, area_fill, style_val, join_style,
412 cap_style, radius, forward_arrow, backward_arrow, npoints);
423 double thickness = round(obj->
penwidth);
426 int depth = st->
Depth;
433 int forward_arrow = 0;
434 int backward_arrow = 0;
435 const size_t npoints = n;
440 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
441 object_code, sub_type, line_style, thickness, pen_color,
442 fill_color, depth, pen_style, area_fill, style_val, join_style,
443 cap_style, radius, forward_arrow, backward_arrow, npoints);
483 "black",
"blue",
"cyan",
"green",
"magenta",
"red",
"white",
"yellow",
Dynamically expanding string buffers.
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
pointf Bezier(const pointf *V, double t, pointf *Left, pointf *Right)
static Extype_t length(Exid_t *rhs, Exdisc_t *disc)
static double dist(int dim, double *x, double *y)
char * agnameof(void *)
returns a string descriptor for the object.
#define GVRENDER_Y_GOES_DOWN
static void color(Agraph_t *g)
void gvputs_nonascii(GVJ_t *job, const char *s)
int gvputs(GVJ_t *job, const char *s)
void gvprintf(GVJ_t *job, const char *format,...)
gvplugin_installed_t gvdevice_fig_types[]
static void fig_ellipse(GVJ_t *job, pointf *A, int filled)
static gvrender_features_t render_features_fig
static void fig_begin_graph(GVJ_t *job)
static gvdevice_features_t device_features_fig
static void fig_begin_job(GVJ_t *job)
static void fig_textspan(GVJ_t *job, pointf p, textspan_t *span)
static char * fig_knowncolors[]
static void fig_end_node(GVJ_t *job)
static void fig_begin_node(GVJ_t *job)
static void fig_end_job(GVJ_t *job)
static int figColorResolve(fig_state_t *st, bool *new, unsigned char r, unsigned char g, unsigned char b)
static void fig_polygon(GVJ_t *job, pointf *A, size_t n, int filled)
gvplugin_installed_t gvrender_fig_types[]
static void fig_line_style(obj_state_t *obj, int *line_style, double *style_val)
static gvrender_engine_t fig_engine
static void fig_begin_page(GVJ_t *job)
static void fig_end_graph(GVJ_t *job)
static void fig_end_edge(GVJ_t *job)
static void fig_comment(GVJ_t *job, char *str)
static void fig_resolve_color(GVJ_t *job, gvcolor_t *color)
static void fig_polyline(GVJ_t *job, pointf *A, size_t n)
static void fig_begin_edge(GVJ_t *job)
#define BEZIERSUBDIVISION
static void fig_bezier(GVJ_t *job, pointf *A, size_t n, int filled)
static void figptarray(GVJ_t *job, pointf *A, size_t n, int close)
textitem scanner parser str
static bool streq(const char *a, const char *b)
are a and b equal?
unsigned char red[maxColors]
unsigned char blue[maxColors]
unsigned char green[maxColors]
PostscriptAlias * postscript_alias
int(* pf)(void *, char *,...)