| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18272e0 commit c0d44bb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -401,6 +401,9 @@ void gp_cairo_draw_polygon(plot_struct *plot, int n, gpiPoint *corners) | |||
| 401 | 401 | /* begin by stroking any open path */ | |
| 402 | 402 | gp_cairo_stroke(plot); | |
| 403 | 403 | ||
| 404 | + if (n <= 0) | ||
| 405 | + return; | ||
| 406 | + | ||
| 404 | 407 | if (plot->polygons_saturate) { | |
| 405 | 408 | int i; | |
| 406 | 409 | path_item *path; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1357,17 +1357,20 @@ void cairotrm_set_color(t_colorspec *colorspec) | |||
| 1357 | 1357 | /* here we send the polygon command */ | |
| 1358 | 1358 | void cairotrm_filled_polygon(int n, gpiPoint *corners) | |
| 1359 | 1359 | { | |
| 1360 | - gpiPoint *mirrored_corners = (gpiPoint*) gp_alloc(n*sizeof(gpiPoint),"mirrored_corners"); | ||
| 1360 | + gpiPoint *corners_copy; | ||
| 1361 | + | ||
| 1362 | + if (n <= 0) | ||
| 1363 | + return; | ||
| 1364 | + | ||
| 1361 | 1365 | /* can't use memcpy() here, as we have to mirror the y axis */ | |
| 1362 | - gpiPoint *corners_copy = mirrored_corners; | ||
| 1363 | - while (corners_copy < (mirrored_corners + n)) { | ||
| 1364 | - *corners_copy = *corners++; | ||
| 1365 | - corners_copy->y = term->ymax - corners_copy->y; | ||
| 1366 | - ++corners_copy; | ||
| 1366 | + corners_copy = gp_alloc(n*sizeof(gpiPoint),"mirrored_corners"); | ||
| 1367 | + for (int i=0; i < n; i++) { | ||
| 1368 | + corners_copy[i] = corners[i]; | ||
| 1369 | + corners_copy[i].y = term->ymax - corners_copy[i].y; | ||
| 1367 | 1370 | } | |
| 1368 | 1371 | ||
| 1369 | - gp_cairo_draw_polygon(&plot, n, mirrored_corners); | ||
| 1370 | - free(mirrored_corners); | ||
| 1372 | + gp_cairo_draw_polygon(&plot, n, corners_copy); | ||
| 1373 | + free(corners_copy); | ||
| 1371 | 1374 | } | |
| 1372 | 1375 | ||
| 1373 | 1376 | void cairotrm_image(unsigned int M, unsigned int N, coordval * image, gpiPoint * corner, t_imagecolor color_mode) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments