Skip to content

Commit

Permalink
Fix #119 support line mitre again
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 committed Oct 24, 2022
1 parent a6cf960 commit 9b311bf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ragg (development version)

* Fixed a regression that turned off line mitre support (#119)

# ragg 1.2.3

* Second attempt at rendering jpegs with transparent background. Now, the buffer
Expand Down
19 changes: 11 additions & 8 deletions src/AggDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ class AggDevice {
}
}
template<class Raster, class Path>
void setStroke(Raster &ras, Path &p, int lty, double lwd, R_GE_lineend lend, R_GE_linejoin ljoin) {
void setStroke(Raster &ras, Path &p, int lty, double lwd, R_GE_lineend lend, R_GE_linejoin ljoin, double lmitre) {
if (lty == LTY_SOLID) {
agg::conv_stroke<Path> pg(p);
pg.width(lwd);
pg.line_join(convertLinejoin(ljoin));
pg.miter_limit(lmitre);
pg.line_cap(convertLineend(lend));
ras.add_path(pg);
} else {
Expand All @@ -198,6 +199,7 @@ class AggDevice {
makeDash(pd, lty, lwd);
pg.width(lwd);
pg.line_join(convertLinejoin(ljoin));
pg.miter_limit(lmitre);
pg.line_cap(convertLineend(lend));
ras.add_path(pg);
}
Expand Down Expand Up @@ -231,7 +233,8 @@ class AggDevice {
template<class Raster, class Path>
void drawShape(Raster &ras, Raster &ras_clip, Path &path, bool draw_fill,
bool draw_stroke, int fill, int col, double lwd,
int lty, R_GE_lineend lend, R_GE_linejoin ljoin = GE_ROUND_JOIN, int pattern = -1, bool evenodd = false) {
int lty, R_GE_lineend lend, R_GE_linejoin ljoin = GE_ROUND_JOIN,
double lmitre = 1.0, int pattern = -1, bool evenodd = false) {
agg::scanline_p8 slp;
if (recording_clip != NULL) {
recording_clip->concat_path(path);
Expand Down Expand Up @@ -283,7 +286,7 @@ class AggDevice {

if (evenodd) ras.filling_rule(agg::fill_non_zero);
agg::scanline_u8 slu;
setStroke(ras, path, lty, lwd, lend, ljoin);
setStroke(ras, path, lty, lwd, lend, ljoin, lmitre);
if (recording_mask == NULL && recording_pattern == NULL) {
solid_renderer.color(convertColour(col));
if (current_mask == NULL) {
Expand Down Expand Up @@ -775,7 +778,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawCircle(double x, double y, double
e1.init(x, y, r, r);
}

drawShape(ras, ras_clip, e1, draw_fill, draw_stroke, fill, col, lwd, lty, lend, GE_ROUND_JOIN, pattern);
drawShape(ras, ras_clip, e1, draw_fill, draw_stroke, fill, col, lwd, lty, lend, GE_ROUND_JOIN, 1.0, pattern);
}

template<class PIXFMT, class R_COLOR, typename BLNDFMT>
Expand Down Expand Up @@ -805,7 +808,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawRect(double x0, double y0, double
rect.line_to(x1, y0);
rect.close_polygon();

drawShape(ras, ras_clip, rect, draw_fill, draw_stroke, fill, col, lwd, lty, lend, GE_ROUND_JOIN, pattern);
drawShape(ras, ras_clip, rect, draw_fill, draw_stroke, fill, col, lwd, lty, lend, GE_ROUND_JOIN, 1.0, pattern);
}

template<class PIXFMT, class R_COLOR, typename BLNDFMT>
Expand All @@ -832,7 +835,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawPolygon(int n, double *x, double *
}
poly.close_polygon();

drawShape(ras, ras_clip, poly, draw_fill, draw_stroke, fill, col, lwd, lty, lend, ljoin, pattern);
drawShape(ras, ras_clip, poly, draw_fill, draw_stroke, fill, col, lwd, lty, lend, ljoin, lmitre, pattern);
}

template<class PIXFMT, class R_COLOR, typename BLNDFMT>
Expand Down Expand Up @@ -874,7 +877,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawPolyline(int n, double* x, double*
ps.line_to(x[i] + x_trans, y[i] + y_trans);
}

drawShape(ras, ras_clip, ps, false, true, 0, col, lwd, lty, lend, ljoin);
drawShape(ras, ras_clip, ps, false, true, 0, col, lwd, lty, lend, ljoin, lmitre);
}

template<class PIXFMT, class R_COLOR, typename BLNDFMT>
Expand Down Expand Up @@ -912,7 +915,7 @@ void AggDevice<PIXFMT, R_COLOR, BLNDFMT>::drawPath(int npoly, int* nper, double*
path.close_polygon();
}

drawShape(ras, ras_clip, path, draw_fill, draw_stroke, fill, col, lwd, lty, lend, ljoin, pattern, evenodd);
drawShape(ras, ras_clip, path, draw_fill, draw_stroke, fill, col, lwd, lty, lend, ljoin, lmitre, pattern, evenodd);
}

template<class PIXFMT, class R_COLOR, typename BLNDFMT>
Expand Down

0 comments on commit 9b311bf

Please sign in to comment.