diff --git a/examples/BoundingBox.cpp b/examples/BoundingBox.cpp index 98aa94d3..3d708dbd 100644 --- a/examples/BoundingBox.cpp +++ b/examples/BoundingBox.cpp @@ -256,10 +256,11 @@ struct UserExample : tvgexam::Example shape->moveTo(0, 0); shape->lineTo(150, 100); shape->lineTo(0, 100); + shape->close(); shape->fill(255, 0, 255); shape->strokeWidth(30); shape->strokeFill(0, 255, 255); - shape->close(); + shape->strokeJoin(tvg::StrokeJoin::Round); tvg::Matrix m = {1.8794f, -0.6840f, 0.0f, 0.6840f, 1.8794f, 0.0f, 0.0f, 0.0f, 1.0f}; shape->transform(m); diff --git a/src/renderer/tvgShape.h b/src/renderer/tvgShape.h index 58ee4d01..2fff92cb 100644 --- a/src/renderer/tvgShape.h +++ b/src/renderer/tvgShape.h @@ -125,10 +125,15 @@ struct ShapeImpl : Shape //Stroke feathering if (stroking && rs.stroke) { - x -= rs.stroke->width * 0.5f; - y -= rs.stroke->width * 0.5f; - w += rs.stroke->width; - h += rs.stroke->width; + //Use geometric mean for feathering. + //Join, Cap wouldn't be considered. Generate stroke outline and compute bbox for accurate size? + auto sx = sqrt(m.e11 * m.e11 + m.e21 * m.e21); + auto sy = sqrt(m.e12 * m.e12 + m.e22 * m.e22); + auto feather = rs.stroke->width * sqrt(sx * sy); + x -= feather * 0.5f; + y -= feather * 0.5f; + w += feather; + h += feather; } pt4[0] = {x, y};