32#define BEZIERSUBDIVISION 6
39 for (
size_t i = 0; i < n; i++) {
56 long rd, gd, bd,
dist;
57 long mindist = 3 * 255 * 255;
60 for (c = 0; c <
top; c++) {
61 rd = (long) (red[c] - r);
62 gd = (long) (green[c] - g);
63 bd = (long) (blue[c] - b);
64 dist = rd * rd + gd * gd + bd * bd;
84static char *
figcolor[] = {
"black",
"blue",
"green",
"cyan",
"red",
85 "magenta",
"yellow",
"white",
NULL};
92 switch (
color->type) {
108 gvprintf(job,
"%d %d #%02x%02x%02x\n",
151 gvputs(job,
"#FIG 3.2\n");
152 gvprintf(job,
"# Generated by %s version %s (%s)\n",
156 gvputs(job,
"Portrait\n");
169 gvputs(job,
"# end of FIG file\n");
225 double height = font_size;
226 double length = 2.0*font_size/3.0 * (double)strlen(span->
str) / 2.0;
232 switch (span->
just) {
252 "%d %d %d %d %d %d %.1f %.4f %d %.1f %.1f %.0f %.0f ",
253 object_code, sub_type,
color, depth, pen_style,
font,
254 font_size, angle, font_flags, height, length, round(p.
x),
267 double thickness = round(obj->
penwidth);
272 int area_fill = filled ? 20 : -1;
276 double center_x, center_y;
280 const double start_x = center_x = round(
A[0].x);
281 const double start_y = center_y = round(
A[0].y);
282 const double radius_x = round(
A[1].x -
A[0].x);
283 const double radius_y = round(
A[1].y -
A[0].y);
284 const double end_x = round(
A[1].x);
285 const double end_y = round(
A[1].y);
288 "%d %d %d %.0f %d %d %d %d %d %.3f %d %.4f %.0f %.0f %.0f %.0f "
289 "%.0f %.0f %.0f %.0f\n",
290 object_code, sub_type, line_style, thickness, pen_color,
291 fill_color, depth, pen_style, area_fill, style_val, direction,
292 angle, center_x, center_y, radius_x, radius_y, start_x,
293 start_y, end_x, end_y);
302 double thickness = round(obj->
penwidth);
310 int forward_arrow = 0;
311 int backward_arrow = 0;
338 for (
size_t i = 0; i + 3 < n; i += 3) {
340 for (
size_t j = 1; j <= 3; j++) {
351 gvprintf(job,
"%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d\n",
361 style_val, cap_style, forward_arrow, backward_arrow, count);
365 for (
int i = 0; i < count; i++) {
366 gvprintf(job,
" %d", i % (count - 1) ? 1 : 0);
377 double thickness = round(obj->
penwidth);
382 int area_fill = filled ? 20 : -1;
387 int forward_arrow = 0;
388 int backward_arrow = 0;
389 const size_t npoints = n + 1;
394 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
395 object_code, sub_type, line_style, thickness, pen_color,
396 fill_color, depth, pen_style, area_fill, style_val, join_style,
397 cap_style, radius, forward_arrow, backward_arrow, npoints);
407 double thickness = round(obj->
penwidth);
417 int forward_arrow = 0;
418 int backward_arrow = 0;
419 const size_t npoints = n;
424 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
425 object_code, sub_type, line_style, thickness, pen_color,
426 fill_color, depth, pen_style, area_fill, style_val, join_style,
427 cap_style, radius, forward_arrow, backward_arrow, npoints);
467 "black",
"blue",
"cyan",
"green",
"magenta",
"red",
"white",
"yellow",
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static char * agxbuse(agxbuf *xb)
pointf Bezier(pointf *V, double t, pointf *Left, pointf *Right)
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 int figColorResolve(bool *new, unsigned char r, unsigned char g, unsigned char b)
gvrender_features_t render_features_fig
static void fig_begin_graph(GVJ_t *job)
gvdevice_features_t device_features_fig
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_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)
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)
static Agedge_t * top(gv_stack_t *sp)
#define PRISIZE_T
PRIu64 alike for printing size_t
static bool streq(const char *a, const char *b)
are a and b equal?
PostscriptAlias * postscript_alias
int(* pf)(void *, char *,...)