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 const size_t span_length = strlen(span->
str);
227 const double length = 2.0 * font_size / 3.0 * (double)span_length / 2.0;
233 switch (span->
just) {
253 "%d %d %d %d %d %d %.1f %.4f %d %.1f %.1f %.0f %.0f ",
254 object_code, sub_type,
color, depth, pen_style,
font,
255 font_size, angle, font_flags, height, length, round(p.
x),
268 double thickness = round(obj->
penwidth);
273 int area_fill = filled ? 20 : -1;
277 double center_x, center_y;
281 const double start_x = center_x = round(
A[0].x);
282 const double start_y = center_y = round(
A[0].y);
283 const double radius_x = round(
A[1].x -
A[0].x);
284 const double radius_y = round(
A[1].y -
A[0].y);
285 const double end_x = round(
A[1].x);
286 const double end_y = round(
A[1].y);
289 "%d %d %d %.0f %d %d %d %d %d %.3f %d %.4f %.0f %.0f %.0f %.0f "
290 "%.0f %.0f %.0f %.0f\n",
291 object_code, sub_type, line_style, thickness, pen_color,
292 fill_color, depth, pen_style, area_fill, style_val, direction,
293 angle, center_x, center_y, radius_x, radius_y, start_x,
294 start_y, end_x, end_y);
303 double thickness = round(obj->
penwidth);
311 int forward_arrow = 0;
312 int backward_arrow = 0;
339 for (
size_t i = 0; i + 3 < n; i += 3) {
341 for (
size_t j = 1; j <= 3; j++) {
352 gvprintf(job,
"%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d\n",
362 style_val, cap_style, forward_arrow, backward_arrow, count);
366 for (
int i = 0; i < count; i++) {
367 gvprintf(job,
" %d", i % (count - 1) ? 1 : 0);
378 double thickness = round(obj->
penwidth);
383 int area_fill = filled ? 20 : -1;
388 int forward_arrow = 0;
389 int backward_arrow = 0;
390 const size_t npoints = n + 1;
395 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
396 object_code, sub_type, line_style, thickness, pen_color,
397 fill_color, depth, pen_style, area_fill, style_val, join_style,
398 cap_style, radius, forward_arrow, backward_arrow, npoints);
408 double thickness = round(obj->
penwidth);
418 int forward_arrow = 0;
419 int backward_arrow = 0;
420 const size_t npoints = n;
425 "%d %d %d %.0f %d %d %d %d %d %.1f %d %d %d %d %d %" PRISIZE_T "\n",
426 object_code, sub_type, line_style, thickness, pen_color,
427 fill_color, depth, pen_style, area_fill, style_val, join_style,
428 cap_style, radius, forward_arrow, backward_arrow, npoints);
468 "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 WUR 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)
textitem scanner parser str
static Agedge_t * top(edge_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 *,...)