#ifndef hxg_ps_H #define hxg_ps_H /* Routines to plot hexagonal canvas pixels and other things. */ /* Last edited on 2009-02-10 09:18:36 by stolfi */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include typedef struct hxg_color_t { float R, G, B; } hxg_color_t; /* Components range in {[0_1]}. In the {pswr} routines, if {R} is negative, the color is "invisible". */ PSStream *hxg_ps_init_plot ( interval_t B[], char *name, bool_t eps, char *paperSize ); /* Creates a Postscript figure stream, and sets up the scales and windows for plotting things in the ranges {B[0],B[1]}. Use the commands in {pswr.h} or {hxg_ps.h} for plotting. Be sure to call {pswr_close_stream} before exiting the program. If {eps=TRUE} the stream will be a set of Encapsulated Postscript figures, about 5 inches wide, called "{name}-{NNNNNN}.eps", for integers {NNNNNN} starting from 0; the {paperSize} is ignored. Otherwise the stream will be a standalone Postscript document with the given {paperSize} ("a4", "a3", etc.) called "{name}.ps". */ void hxg_ps_plot_pixels ( PSStream *ps, /* Where to plot. */ hxg_canvas_t *cvs, /* The canvas to plot. */ double pixv[], /* Pixel values, stored in the standard way. */ int maxv, /* Max pixel value in tables. */ double *r, /* Radius table. */ hxg_color_t *fc, /* Fill color table. */ hxg_color_t *dc /* Draw color table. */ ); /* Plots the pixels of the canvas {cvs} into the Postscript file {f}. A pixel with value {v} in the range {0..maxv} is plotted as a circle with radius {r[v]} filled with color {fc[v]} and drawd with color {dc[v]}. If the pixel value {v} is negative, the absolute value is used, but the fill color is complemented. Pixel values exceeding {maxv} are painted as {maxv}. */ void hxg_ps_fill_polygon(PSStream *ps, r2_vec_t *p); /* Fills the polygon {p} using the current fill color. */ void hxg_ps_draw_polyline(PSStream *ps, r2_vec_t *p); /* Draws the polyline(s) whose vertices are {p} using the current pen width and dash settings, and the current draw color. */ void hxg_ps_plot_circle ( PSStream *ps, /* Where to plot. */ r2_t *c, /* Center of circle. */ double r, /* Radius of circle. */ bool_t fill, bool_t draw /* Plotting options. */ ); /* Fills and/or draws the circle with center {c} and radius {r} using the current pen width and dash settings, and the current fill and draw colors. */ void hxg_ps_plot_dot ( PSStream *ps, /* Where to plot. */ r2_t *c, /* Center of circle. */ double r, /* Radius of circle (mm). */ bool_t fill, bool_t draw /* Plotting options. */ ); /* Same as {hxg_ps_plot_circle}, except that the radius is in actual millimeters, irrespective of the current scale. */ void hxg_ps_plot_rect_stroke ( PSStream *ps, /* Where to plot. */ r2_t *a, /* Start of stroke. */ r2_t *b, /* End of stroke. */ double r, /* Half-width of stroke. */ bool_t fill, bool_t draw /* Plotting options. */ ); /* Fills and/or draws the circle with center {c} and radius {r} using the current pen width and dash settings, and the current fill and draw colors. */ void hxg_ps_fill_circles ( PSStream *ps, /* Where to plot. */ r2_vec_t *c, /* Centers of circles. */ double_vec_t *h, /* Individual radii. */ double r /* Fixed radius. */ ); /* Calls {hxg_ps_plot_circle(ps, c[k], h[k]+r, TRUE, FALSE)} for all the {k}. If {h} is NULL or shorter than {c}, the missing entries are assumed to be 0. */ void hxg_ps_fill_dots ( PSStream *ps, /* Where to plot. */ r2_vec_t *c, /* Centers of circles. */ double r /* Dot radius (mm). */ ); /* Calls {hxg_ps_plot_dot(ps, c[k], r, TRUE, FALSE)} for all the {k}. */ void hxg_ps_show_labels ( PSStream *ps, /* Where to plot. */ r2_vec_t *c, /* Reference points. */ r2_t disp, /* Extra displacement for all ref pts. */ double xalign, /* Horiz rel pos of label to align with ref X. */ double yalign, /* Vert rel pos of label to align with ref Y. */ double ptsize /* Text point size. */ ); /* For each {k} in {0..c.ne-1}, writes the string "{k}" at the point {c[k] + disp}, with font of size {ptsize}. The parameters {xalign} and {yalign} behave as in {pswr_label}. */ void hxg_ps_draw_circles ( PSStream *ps, /* Where to plot. */ r2_vec_t *c, /* Centers of circles. */ double_vec_t *h, /* Individual radii. */ double r /* Fixed radius. */ ); /* Calls {hxg_ps_plot_circle(ps, c[k], h[k]+r, FALSE, TRUE)} for all the {k}. If {h} is NULL or shorter than {c}, the missing entries are assumed to be 0. */ void hxg_ps_fill_sausage ( PSStream *ps, /* Where to plot. */ r2_vec_t *p, /* Vertices of sausage. */ double r /* Half-width of sausage. */ ); /* Fills the sausage-shape with half-width {r} whose skeleton is the polyline {p}. Said another way, strokes the polyline {p} with a round pen of radius {r} --- but with the current *fill* color. Equivalent to {hxg_ps_plot_circle(ps, p[k], r, TRUE, FALSE)} for every finite point {p[k]}, and {hxg_ps_plot_rect_stroke(ps, p[k-1], p[k], r, TRUE, FALSE)} for all consecutive finite point pairs {p[k-1], p[k]}. */ #endif