fix path addrrect example in docs
Use drawTextRSXform in place of deprecated SkDrawTextOnPath
in example. I'm curious if there is a more elegant way to
illustrate where round rects start, but this is all I've
come up with.
R=reed@google.com,fmalita@google.com
NOTRY=true
Docs-Preview: https://skia.org/?cl=158444
Bug: skia:
Change-Id: I0fc02078e6425afabb5dc71f458435d606c82e77
Reviewed-on: https://skia-review.googlesource.com/158444
Commit-Queue: Cary Clark <caryclark@google.com>
Auto-Submit: Cary Clark <caryclark@skia.org>
Reviewed-by: Florin Malita <fmalita@chromium.org>
diff --git a/docs/SkPath_Reference.bmh b/docs/SkPath_Reference.bmh
index 1199de1..b0a7369 100644
--- a/docs/SkPath_Reference.bmh
+++ b/docs/SkPath_Reference.bmh
@@ -4415,13 +4415,26 @@
#Example
void draw(SkCanvas* canvas) {
- SkPaint paint;
- paint.setAntiAlias(true);
- SkRRect rrect;
- rrect.setRectXY({40, 40, 215, 215}, 50, 50);
- SkPath path;
- path.addRRect(rrect);
- canvas->drawPath(path, paint);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ SkRRect rrect;
+ rrect.setRectXY({40, 40, 215, 215}, 50, 50);
+ SkPath path;
+ path.addRRect(rrect);
+ canvas->drawPath(path, paint);
+ for (int start = 0; start < 8; ++start) {
+ SkPath textPath;
+ textPath.addRRect(rrect, SkPath::kCW_Direction, start);
+ SkPathMeasure pathMeasure(textPath, false);
+ SkPoint position;
+ SkVector tangent;
+ if (!pathMeasure.getPosTan(0, &position, &tangent)) {
+ continue;
+ }
+ SkRSXform rsxForm = SkRSXform::Make(tangent.fX, tangent.fY,
+ position.fX + tangent.fY * 5, position.fY - tangent.fX * 5);
+ canvas->drawTextRSXform(&"01234567"[start], 1, &rsxForm, nullptr, paint);
+ }
}
##
diff --git a/site/user/api/SkPath_Reference.md b/site/user/api/SkPath_Reference.md
index b455e80..c2b827b 100644
--- a/site/user/api/SkPath_Reference.md
+++ b/site/user/api/SkPath_Reference.md
@@ -4936,7 +4936,7 @@
### Example
-<div><fiddle-embed name="0e6ca92d854035da29e89ad81d85ff85"></fiddle-embed></div>
+<div><fiddle-embed name="888edd4c4a91ca62ceb01bce8ab675b2"></fiddle-embed></div>
### See Also
diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm
index fe718d5..62210b4 100644
--- a/site/user/api/catalog.htm
+++ b/site/user/api/catalog.htm
@@ -7513,10 +7513,10 @@
"name": "SkPath::addRRect"
},
"SkPath_addRRect_2": {
- "code": "#include \"SkTextOnPath.h\"\n\nvoid draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setAntiAlias(true);\n SkRRect rrect;\n rrect.setRectXY({40, 40, 215, 215}, 50, 50);\n SkPath path;\n path.addRRect(rrect);\n canvas->drawPath(path, paint);\n for (int start = 0; start < 8; ++start) {\n SkPath textPath;\n textPath.addRRect(rrect, SkPath::kCW_Direction, start);\n SkMatrix matrix;\n matrix.setTranslate(0, -5);\n SkDrawTextOnPath(&\"01234567\"[start], 1, paint, textPath, &matrix, canvas);\n }\n}\n",
+ "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setAntiAlias(true);\n SkRRect rrect;\n rrect.setRectXY({40, 40, 215, 215}, 50, 50);\n SkPath path;\n path.addRRect(rrect);\n canvas->drawPath(path, paint);\n for (int start = 0; start < 8; ++start) {\n SkPath textPath;\n textPath.addRRect(rrect, SkPath::kCW_Direction, start);\n SkPathMeasure pathMeasure(textPath, false);\n SkPoint position;\n SkVector tangent;\n if (!pathMeasure.getPosTan(0, &position, &tangent)) {\n continue;\n }\n SkRSXform rsxForm = SkRSXform::Make(tangent.fX, tangent.fY,\n position.fX + tangent.fY * 5, position.fY - tangent.fX * 5);\n canvas->drawTextRSXform(&\"01234567\"[start], 1, &rsxForm, nullptr, paint);\n }\n}\n",
"width": 256,
"height": 256,
- "hash": "0e6ca92d854035da29e89ad81d85ff85",
+ "hash": "888edd4c4a91ca62ceb01bce8ab675b2",
"file": "SkPath_Reference",
"name": "SkPath::addRRect_2"
},