aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkPath.h
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-01-23 05:07:04 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-23 05:07:04 -0800
commit55d49053d1b6db42e013eb3409ffcfc7e235c685 (patch)
treec424605b65aceb748643ecb9e6b66193f362d54b /include/core/SkPath.h
parentb714fb0199e8727ef2b6cddbee7eba6046f01554 (diff)
Add svg path arcto
The arcto() used by SVG in Chrome and Android is ported here, using conics instead of cubics. The logic is a direct transposition of the WebKit code. The attached GM includes SVG that draws the same as Skia. R=reed@google.com BUG=skia:3959 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1613303002 Review URL: https://codereview.chromium.org/1613303002
Diffstat (limited to 'include/core/SkPath.h')
-rw-r--r--include/core/SkPath.h52
1 files changed, 48 insertions, 4 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 6952719815..7c6fd35d5a 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -499,10 +499,12 @@ public:
this->arcTo(p1.fX, p1.fY, p2.fX, p2.fY, radius);
}
- /** Close the current contour. If the current point is not equal to the
- first point of the contour, a line segment is automatically added.
- */
- void close();
+ enum ArcSize {
+ /** the smaller of the two possible SVG arcs. */
+ kSmall_ArcSize,
+ /** the larger of the two possible SVG arcs. */
+ kLarge_ArcSize,
+ };
enum Direction {
/** clockwise direction for adding closed contours */
@@ -512,6 +514,48 @@ public:
};
/**
+ * Append an elliptical arc from the current point in the format used by SVG.
+ * The center of the ellipse is computed to satisfy the constraints below.
+ *
+ * @param rx,ry The radii in the x and y directions respectively.
+ * @param xAxisRotate The angle in degrees relative to the x-axis.
+ * @param largeArc Determines whether the smallest or largest arc possible
+ * is drawn.
+ * @param sweep Determines if the arc should be swept in an anti-clockwise or
+ * clockwise direction. Note that this enum value is opposite the SVG
+ * arc sweep value.
+ * @param x,y The destination coordinates.
+ */
+ void arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
+ Direction sweep, SkScalar x, SkScalar y);
+
+ void arcTo(const SkPoint r, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep,
+ const SkPoint xy) {
+ this->arcTo(r.fX, r.fY, xAxisRotate, largeArc, sweep, xy.fX, xy.fY);
+ }
+
+ /** Same as arcTo format used by SVG, but the destination coordinate is relative to the
+ * last point on this contour. If there is no previous point, then a
+ * moveTo(0,0) is inserted automatically.
+ *
+ * @param rx,ry The radii in the x and y directions respectively.
+ * @param xAxisRotate The angle in degrees relative to the x-axis.
+ * @param largeArc Determines whether the smallest or largest arc possible
+ * is drawn.
+ * @param sweep Determines if the arc should be swept in an anti-clockwise or
+ * clockwise direction. Note that this enum value is opposite the SVG
+ * arc sweep value.
+ * @param dx,dy The destination coordinates relative to the last point.
+ */
+ void rArcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc,
+ Direction sweep, SkScalar dx, SkScalar dy);
+
+ /** Close the current contour. If the current point is not equal to the
+ first point of the contour, a line segment is automatically added.
+ */
+ void close();
+
+ /**
* Returns whether or not a fill type is inverted
*
* kWinding_FillType -> false