| 4332 | } |
| 4333 | |
| 4334 | int 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 |
| 4373 | int 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 |
no test coverage detected