MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / PSL_plotline

Function PSL_plotline

src/postscriptlight.c:4334–4371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4332}
4333
4334int PSL_plotline (struct PSL_CTRL *PSL, double *x, double *y, int n, int type) {
4335 /* Plot a (portion of a) line. This can be a line from start to finish, or a portion of it, depending
4336 * on the type argument. Optionally, the line can be stroked (using the current pen), closed.
4337 * Type is a combination of the following:
4338 * PSL_DRAW (0) : Draw a line segment
4339 * PSL_MOVE (1) : Move to a new anchor point (x[0], y[0]) first
4340 * PSL_STROKE (2) : Stroke the line
4341 * PSL_CLOSE (8) : Close the line back to the beginning of this segment, this is done automatically
4342 * when the first and last point are the same and PSL_MOVE is on.
4343 */
4344 int i, i0 = 0;
4345
4346 if (n < 1) return (PSL_NO_ERROR); /* Cannot deal with empty lines */
4347 if (type < 0) type = -type; /* Should be obsolete now */
4348
4349 /* If first and last point are the same, close the polygon and drop the last point
4350 * (but only if this segment runs start to finish)
4351 */
4352
4353 if (n > 1 && (type & PSL_MOVE) && (x[0] == x[n-1] && y[0] == y[n-1]) && (type & PSL_CLOSE_INTERIOR) == 0) {n--; type |= PSL_CLOSE;}
4354
4355 if (type & PSL_MOVE) {
4356 PSL_command (PSL, "%.12lg %.12lg M\n", psl_x (PSL, x[0]), psl_y (PSL, y[0]));
4357 i0++;
4358 if (n == 1) PSL_command (PSL, "0 0 D\n"); /* Add at least a zero length line */
4359 }
4360
4361 for (i = i0; i < n; i++)
4362 PSL_command (PSL, "%.12lg %.12lg L\n", psl_x (PSL, x[i]), psl_y (PSL, y[i]));
4363 if (type & PSL_STROKE && type & PSL_CLOSE)
4364 PSL_command (PSL, "P S\n"); /* Close and stroke the path */
4365 else if (type & PSL_CLOSE)
4366 PSL_command (PSL, "P\n"); /* Close the path */
4367 else if (type & PSL_STROKE)
4368 PSL_command (PSL, "S\n"); /* Stroke the path */
4369
4370 return (PSL_NO_ERROR);
4371}
4372#else
4373int PSL_plotline (struct PSL_CTRL *PSL, double *x, double *y, int n, int type) {
4374 /* Plot a (portion of a) line. This can be a line from start to finish, or a portion of it, depending

Callers 15

gmtplot_vertical_wallFunction · 0.85
gmtplot_cube_boxFunction · 0.85
gmtplot_draw_dir_roseFunction · 0.85
gmt_plot_lineFunction · 0.85
gmt_draw_map_insetFunction · 0.85
gmt_draw_map_scaleFunction · 0.85
gmt_draw_vertical_scaleFunction · 0.85

Calls 4

PSL_commandFunction · 0.85
psl_xFunction · 0.85
psl_yFunction · 0.85
psl_convert_pathFunction · 0.85

Tested by

no test coverage detected