diff options
-rw-r--r-- | gm/arcto.cpp | 20 | ||||
-rw-r--r-- | src/core/SkPath.cpp | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/gm/arcto.cpp b/gm/arcto.cpp index 900c6b30ea..aac9bde1b3 100644 --- a/gm/arcto.cpp +++ b/gm/arcto.cpp @@ -35,6 +35,12 @@ The arcto test below should draw the same as this SVG: <path d="M250,400 A120,80 0 0,1 250,500" fill="none" stroke="blue" stroke-width="5"/> + +<path d="M100,100 A 0, 0 0 0,1 200,200" + fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/> + +<path d="M200,100 A 80,80 0 0,1 200,100" + fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/> </svg> */ @@ -44,7 +50,7 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) { paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(2); paint.setColor(0xFF660000); - canvas->scale(2, 2); +// canvas->scale(2, 2); // for testing on retina SkRect oval = SkRect::MakeXYWH(100, 100, 100, 100); SkPath svgArc; @@ -83,4 +89,16 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) { paint.setColor(colors[cIndex++]); canvas->drawPath(svgArc, paint); } + + // test that zero length arcs still draw round cap + paint.setStrokeCap(SkPaint::kRound_Cap); + SkPath path; + path.moveTo(100, 100); + path.arcTo(0, 0, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 200); + canvas->drawPath(path, paint); + + path.reset(); + path.moveTo(200, 100); + path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 100); + canvas->drawPath(path, paint); } diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp index 40ca50b5ca..75a4cdcd7a 100644 --- a/src/core/SkPath.cpp +++ b/src/core/SkPath.cpp @@ -1271,12 +1271,14 @@ void SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize arc // joining the endpoints. // http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters if (!rx || !ry) { + this->lineTo(x, y); return; } // If the current point and target point for the arc are identical, it should be treated as a // zero length path. This ensures continuity in animations. srcPts[1].set(x, y); if (srcPts[0] == srcPts[1]) { + this->lineTo(x, y); return; } rx = SkScalarAbs(rx); |