From 153e76d4bf870f0247e9f1ec29f29b7f2108553a Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Tue, 28 Aug 2018 11:48:28 -0400 Subject: [PATCH] deprecate draw text on path in docs Remove documentation, see also references, and examples that rely on SkCanvas::drawTextOnPath(HV). Move example that uses SkDrawTextOnPath into illustrations. TBR=reed@google.com Docs-Preview: https://skia.org/?cl=150020 Bug: skia:6898 Change-Id: I1d92f258b75a8a10a6aa89ebf9380871ba7ecac5 Reviewed-on: https://skia-review.googlesource.com/150020 Commit-Queue: Cary Clark Reviewed-by: Cary Clark --- docs/SkCanvas_Reference.bmh | 115 ++----------------------- docs/SkPaint_Reference.bmh | 3 +- docs/SkPath_Reference.bmh | 125 +++++----------------------- docs/illustrations.bmh | 95 +++++++++++++++++++++ include/core/SkCanvas.h | 57 +------------ include/core/SkPaint.h | 5 +- site/user/api/SkCanvas_Reference.md | 123 ++------------------------- site/user/api/SkPaint_Reference.md | 3 +- site/user/api/SkPath_Reference.md | 33 +++++--- site/user/api/catalog.htm | 38 +++------ 10 files changed, 170 insertions(+), 427 deletions(-) diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 8ec893dfab..08f1dd3f47 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -5107,7 +5107,7 @@ void draw(SkCanvas* canvas) { } ## -#SeeAlso drawString drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform +#SeeAlso drawString drawPosText drawPosTextH drawTextBlob drawTextRSXform ## @@ -5143,7 +5143,7 @@ filled 12 point black Glyphs. canvas->drawString("a small hello", 20, 20, paint); ## -#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform +#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextRSXform ## @@ -5177,7 +5177,7 @@ filled 12 point black Glyphs. canvas->drawString(string, 20, 20, paint); ## -#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform +#SeeAlso drawText drawPosText drawPosTextH drawTextBlob drawTextRSXform ## @@ -5222,7 +5222,7 @@ void draw(SkCanvas* canvas) { } ## -#SeeAlso drawText drawPosTextH drawTextBlob drawTextOnPath drawTextRSXform +#SeeAlso drawText drawPosTextH drawTextBlob drawTextRSXform ## @@ -5267,7 +5267,7 @@ baseline. } ## -#SeeAlso drawText drawPosText drawTextBlob drawTextOnPath drawTextRSXform +#SeeAlso drawText drawPosText drawTextBlob drawTextRSXform ## @@ -5275,111 +5275,12 @@ baseline. #Method void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path, SkScalar hOffset, SkScalar vOffset, const SkPaint& paint) -#In Draw_Text -#In Draw -#Line # draws text following Path with offsets ## - -Draws text on Path path, using Clip, Matrix, and Paint paint. - -Origin of text is at distance hOffset along the path, offset by a perpendicular -vector of length vOffset. If the path section corresponding the glyph advance is -curved, the glyph is drawn curved to match; control points in the glyph are -mapped to projected points parallel to the path. If the text advance is larger -than the path length, the excess text is clipped. - -text meaning depends on Paint_Text_Encoding; by default, text is encoded as -UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by -default text positions the first glyph left side bearing and baseline relative -to origin. Text size is affected by Matrix and Paint_Text_Size. - -All elements of paint: Path_Effect, Mask_Filter, Shader, -Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws -filled 12 point black Glyphs. - -#Param text character code points or Glyphs drawn ## -#Param byteLength byte length of text array ## -#Param path Path providing text baseline ## -#Param hOffset distance along path to offset origin ## -#Param vOffset offset of text above (if negative) or below (if positive) the path ## -#Param paint text size, blend, color, and so on, used to draw ## - -#Example - void draw(SkCanvas* canvas) { - const char aero[] = "correo a" "\xC3" "\xA9" "reo"; - const size_t len = sizeof(aero) - 1; - SkPath path; - path.addOval({43-26, 43-26, 43+26, 43+26}, SkPath::kCW_Direction, 3); - SkPaint paint; - paint.setTextSize(24); - for (auto offset : { 0, 10, 20 } ) { - canvas->drawTextOnPathHV(aero, len, path, 0, -offset, paint); - canvas->translate(70 + offset, 70 + offset); - } - } +#Deprecated ## -#SeeAlso drawTextOnPath drawText drawPosTextH drawTextBlob drawTextRSXform - -## - -# ------------------------------------------------------------------------------ - #Method void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) -#In Draw_Text -#In Draw -#Line # draws text following Path contour ## - -Draws text on Path path, using Clip, Matrix, and Paint paint. - -Origin of text is at beginning of path offset by matrix, if not nullptr. -matrix transforms text before text is mapped to path. If the path section -corresponding the glyph advance is curved, the glyph is drawn curved to match; -control points in the glyph are mapped to projected points parallel to the path. -If the text advance is larger than the path length, the excess text is clipped. - -matrix does not effect paint Shader. - -text meaning depends on Paint_Text_Encoding; by default, text is encoded as -UTF-8. Origin meaning depends on Paint_Text_Align and Paint_Vertical_Text; by -default text positions the first glyph left side bearing and baseline relative -to origin. Text size is affected by matrix parameter, Canvas Matrix, -and Paint_Text_Size. - -All elements of paint: Path_Effect, Mask_Filter, Shader, -Color_Filter, Image_Filter, and Draw_Looper; apply to text. By default, draws -filled 12 point black Glyphs. - -#Param text character code points or Glyphs drawn ## -#Param byteLength byte length of text array ## -#Param path Path providing text baseline ## -#Param matrix transform of Glyphs before mapping to path; may be nullptr - to use identity Matrix -## -#Param paint text size, blend, color, and so on, used to draw ## - -#Example - void draw(SkCanvas* canvas) { - const char roller[] = "rollercoaster"; - const size_t len = sizeof(roller) - 1; - SkPath path; - path.cubicTo(40, -80, 120, 80, 160, -40); - SkPaint paint; - paint.setTextSize(32); - paint.setStyle(SkPaint::kStroke_Style); - SkMatrix matrix; - matrix.setIdentity(); - for (int i = 0; i < 3; ++i) { - canvas->translate(25, 60); - canvas->drawPath(path, paint); - canvas->drawTextOnPath(roller, len, path, &matrix, paint); - matrix.preTranslate(0, 10); - } - } -## - -#SeeAlso drawTextOnPathHV drawText drawPosTextH drawTextBlob drawTextRSXform - +#Deprecated ## # ------------------------------------------------------------------------------ @@ -5431,7 +5332,7 @@ void draw(SkCanvas* canvas) { } ## -#SeeAlso drawTextOnPath drawTextOnPathHV drawText drawPosText drawTextBlob +#SeeAlso drawText drawPosText drawTextBlob ## diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh index 8a5e87a5b2..f1cd26225a 100644 --- a/docs/SkPaint_Reference.bmh +++ b/docs/SkPaint_Reference.bmh @@ -3477,8 +3477,7 @@ Increments drawLooper Reference_Count by one. Align adjusts the text relative to the text position. Align affects Glyphs drawn with: SkCanvas::drawText, SkCanvas::drawPosText, -SkCanvas::drawPosTextH, SkCanvas::drawTextOnPath, -SkCanvas::drawTextOnPathHV, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, +SkCanvas::drawPosTextH, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, and SkCanvas::drawString; as well as calls that place text Glyphs like getTextWidths and getTextPath. diff --git a/docs/SkPath_Reference.bmh b/docs/SkPath_Reference.bmh index b41fe22ecf..23736fb5af 100644 --- a/docs/SkPath_Reference.bmh +++ b/docs/SkPath_Reference.bmh @@ -3023,15 +3023,11 @@ conicTo describes Arc of less than 180 degrees as a pair of tangent lines and Co conicTo can represent any Arc with a sweep less than 180 degrees at any rotation. All arcTo constructions are converted to Conic data when added to Path. -#ToDo allow example to hide source and not be exposed as fiddle since markdown / html can't - do the kind of table shown in the illustration. - example is spaced correctly on fiddle but spacing is too wide on pc +#ToDo example is spaced correctly on fiddle but spacing is too wide on pc ## -#Example -#Height 300 -#Width 600 -#Description +#Illustration + #List # 1 arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo) ## # 2 parameter sets force MoveTo ## @@ -3040,105 +3036,9 @@ constructions are converted to Conic data when added to Path. # 5 arcTo(SkScalar rx, SkScalar ry, SkScalar xAxisRotate, ArcSize largeArc, Direction sweep, SkScalar x, SkScalar y) ## #List ## -#Description ## -#Function -###$ -struct data { - const char* name; - char super; - int yn[10]; -}; - -const data dataSet[] = { -{ "arcTo sweep", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }}, -{ "drawArc", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }}, -{ "addArc", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }}, -{ "arcTo tangents", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }}, -{ "arcTo radii", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }}, -{ "conicTo", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }} -}; - -#define __degree_symbol__ "\xC2" "\xB0" - -const char* headers[] = { - "Oval part", - "force moveTo", - "can draw 180" __degree_symbol__, - "can draw 360" __degree_symbol__, - "can draw greater than 360" __degree_symbol__, - "ignored if radius is zero", - "ignored if sweep is zero", - "requires Path", - "describes rotation", - "describes perspective", -}; - -const char* yna[] = { - "n/a", - "no", - "yes" -}; -$$$# -## -void draw(SkCanvas* canvas) { - SkPaint lp; - lp.setAntiAlias(true); - SkPaint tp(lp); - SkPaint sp(tp); - SkPaint bp(tp); - bp.setFakeBoldText(true); - sp.setTextSize(10); - lp.setColor(SK_ColorGRAY); - canvas->translate(0, 32); - const int tl = 115; - for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) { - canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp); - if (0 == col) { - continue; - } - canvas->drawLine(tl + col * 35, 100, tl + 100 + col * 35, 0, lp); - SkPath path; - path.moveTo(tl - 3 + col * 35, 103); - path.lineTo(tl + 124 + col * 35, -24); - canvas->drawTextOnPathHV(headers[col -1], strlen(headers[col -1]), path, 0, -9, bp); - } - for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) { - if (0 == row) { - canvas->drawLine(tl, 100, tl + 350, 100, lp); - } else { - canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp); - } - if (row == SK_ARRAY_COUNT(dataSet)) { - break; - } - canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp); - if (dataSet[row].super) { - SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name)); - canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp); - } - for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) { - int val = dataSet[row].yn[col]; - canvas->drawString(yna[SkTMin(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp); - if (val > 1) { - char supe = '0' + val - 1; - canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp); - } - } - } -} -#Example ## #Example #Height 128 -#Description -#ToDo make this a list or table ## -1 describes an arc from an oval, a starting angle, and a sweep angle. -2 is similar to 1, but does not require building a path to draw. -3 is similar to 1, but always begins new Contour. -4 describes an arc from a pair of tangent lines and a radius. -5 describes an arc from Oval center, arc start Point and arc end Point. -6 describes an arc from a pair of tangent lines and a Conic_Weight. -## void draw(SkCanvas* canvas) { SkRect oval = {8, 8, 56, 56}; SkPaint ovalPaint; @@ -3180,6 +3080,15 @@ void draw(SkCanvas* canvas) { } #Example ## +In the example above: +#List +# 1 describes an arc from an oval, a starting angle, and a sweep angle. ## +# 2 is similar to 1, but does not require building a path to draw. ## +# 3 is similar to 1, but always begins new Contour. ## +# 4 describes an arc from a pair of tangent lines and a radius. ## +# 5 describes an arc from Oval center, arc start Point and arc end Point. ## +# 6 describes an arc from a pair of tangent lines and a Conic_Weight. ## +#List ## #Method SkPath& arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo) #In Build @@ -4500,6 +4409,11 @@ After appending, Path may be empty, or may contain: Rect, Oval, or Round_Rect. #Return reference to Path ## #Example +###$ +$Function +#include "SkTextOnPath.h" +$$ + void draw(SkCanvas* canvas) { SkPaint paint; paint.setAntiAlias(true); @@ -4511,9 +4425,12 @@ void draw(SkCanvas* canvas) { for (int start = 0; start < 8; ++start) { SkPath textPath; textPath.addRRect(rrect, SkPath::kCW_Direction, start); - canvas->drawTextOnPathHV(&"01234567"[start], 1, textPath, 0, -5, paint); + SkMatrix matrix; + matrix.setTranslate(0, -5); + SkDrawTextOnPath(&"01234567"[start], 1, paint, textPath, &matrix, canvas); } } +$$$# ## #SeeAlso addRoundRect SkCanvas::drawRRect diff --git a/docs/illustrations.bmh b/docs/illustrations.bmh index 0558722029..49318df832 100644 --- a/docs/illustrations.bmh +++ b/docs/illustrations.bmh @@ -718,4 +718,99 @@ void draw(SkCanvas* canvas) { ## ## +#Subtopic Path_Arc +#Example +#Height 300 +#Width 600 +#Function +###$ +#include "SkTextOnPath.h" +struct data { + const char* name; + char super; + int yn[10]; +}; + +const data dataSet[] = { +{ "arcTo sweep", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }}, +{ "drawArc", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }}, +{ "addArc", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }}, +{ "arcTo tangents", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }}, +{ "arcTo radii", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }}, +{ "conicTo", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }} +}; + +#define __degree_symbol__ "\xC2" "\xB0" + +const char* headers[] = { + "Oval part", + "force moveTo", + "can draw 180" __degree_symbol__, + "can draw 360" __degree_symbol__, + "can draw greater than 360" __degree_symbol__, + "ignored if radius is zero", + "ignored if sweep is zero", + "requires Path", + "describes rotation", + "describes perspective", +}; + +const char* yna[] = { + "n/a", + "no", + "yes" +}; +$$$# +## +void draw(SkCanvas* canvas) { + SkPaint lp; + lp.setAntiAlias(true); + SkPaint tp(lp); + SkPaint sp(tp); + SkPaint bp(tp); + bp.setFakeBoldText(true); + sp.setTextSize(10); + lp.setColor(SK_ColorGRAY); + canvas->translate(0, 32); + const int tl = 115; + for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) { + canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp); + if (0 == col) { + continue; + } + canvas->drawLine(tl + col * 35, 100, tl + 100 + col * 35, 0, lp); + SkPath path; + path.moveTo(tl - 3 + col * 35, 103); + path.lineTo(tl + 124 + col * 35, -24); + SkMatrix matrix; + matrix.setTranslate(0, -9); + SkDrawTextOnPath(headers[col -1], strlen(headers[col -1]), bp, path, &matrix, canvas); + } + for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) { + if (0 == row) { + canvas->drawLine(tl, 100, tl + 350, 100, lp); + } else { + canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp); + } + if (row == SK_ARRAY_COUNT(dataSet)) { + break; + } + canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp); + if (dataSet[row].super) { + SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name)); + canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp); + } + for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) { + int val = dataSet[row].yn[col]; + canvas->drawString(yna[SkTMin(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp); + if (val > 1) { + char supe = '0' + val - 1; + canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp); + } + } + } +} +#Example ## +## + #Topic Illustrations ## diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index a578ec332f..ae2b332701 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -6,7 +6,7 @@ */ /* Generated by tools/bookmaker from include/core/SkCanvas.h and docs/SkCanvas_Reference.bmh - on 2018-08-10 12:59:44. Additional documentation and examples can be found at: + on 2018-08-28 10:32:58. Additional documentation and examples can be found at: https://skia.org/user/api/SkCanvas_Reference You may edit either file directly. Structural changes to public interfaces require @@ -1946,63 +1946,12 @@ public: void drawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], SkScalar constY, const SkPaint& paint); - /** Draws text on SkPath path, using clip, SkMatrix, and SkPaint paint. - - DEPRECATED - - Origin of text is at distance hOffset along the path, offset by a perpendicular - vector of length vOffset. If the path section corresponding the glyph advance is - curved, the glyph is drawn curved to match; control points in the glyph are - mapped to projected points parallel to the path. If the text advance is larger - than the path length, the excess text is clipped. - - text meaning depends on SkPaint::TextEncoding; by default, text is encoded as - UTF-8. Origin meaning depends on SkPaint::Align and SkPaint vertical text; by - default text positions the first glyph left side bearing and baseline relative - to origin. Text size is affected by SkMatrix and SkPaint text size. - - All elements of paint: SkPathEffect, SkMaskFilter, SkShader, - SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws - filled 12 point black glyphs. - - @param text character code points or glyphs drawn - @param byteLength byte length of text array - @param path SkPath providing text baseline - @param hOffset distance along path to offset origin - @param vOffset offset of text above (if negative) or below (if positive) the path - @param paint text size, blend, color, and so on, used to draw + /** Deprecated. */ void drawTextOnPathHV(const void* text, size_t byteLength, const SkPath& path, SkScalar hOffset, SkScalar vOffset, const SkPaint& paint); - /** Draws text on SkPath path, using clip, SkMatrix, and SkPaint paint. - - DEPRECATED - - Origin of text is at beginning of path offset by matrix, if not nullptr. - matrix transforms text before text is mapped to path. If the path section - corresponding the glyph advance is curved, the glyph is drawn curved to match; - control points in the glyph are mapped to projected points parallel to the path. - If the text advance is larger than the path length, the excess text is clipped. - - matrix does not effect paint SkShader. - - text meaning depends on SkPaint::TextEncoding; by default, text is encoded as - UTF-8. Origin meaning depends on SkPaint::Align and SkPaint vertical text; by - default text positions the first glyph left side bearing and baseline relative - to origin. Text size is affected by matrix parameter, SkCanvas SkMatrix, - and SkPaint text size. - - All elements of paint: SkPathEffect, SkMaskFilter, SkShader, - SkColorFilter, SkImageFilter, and SkDrawLooper; apply to text. By default, draws - filled 12 point black glyphs. - - @param text character code points or glyphs drawn - @param byteLength byte length of text array - @param path SkPath providing text baseline - @param matrix transform of glyphs before mapping to path; may be nullptr - to use identity SkMatrix - @param paint text size, blend, color, and so on, used to draw + /** Deprecated. */ void drawTextOnPath(const void* text, size_t byteLength, const SkPath& path, const SkMatrix* matrix, const SkPaint& paint); diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 6492a3a395..46cf3086a3 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -6,7 +6,7 @@ */ /* Generated by tools/bookmaker from include/core/SkPaint.h and docs/SkPaint_Reference.bmh - on 2018-07-13 08:15:10. Additional documentation and examples can be found at: + on 2018-08-28 10:32:58. Additional documentation and examples can be found at: https://skia.org/user/api/SkPaint_Reference You may edit either file directly. Structural changes to public interfaces require @@ -847,8 +847,7 @@ public: /** \enum SkPaint::Align Align adjusts the text relative to the text position. Align affects glyphs drawn with: SkCanvas::drawText, SkCanvas::drawPosText, - SkCanvas::drawPosTextH, SkCanvas::drawTextOnPath, - SkCanvas::drawTextOnPathHV, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, + SkCanvas::drawPosTextH, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, and SkCanvas::drawString; as well as calls that place text glyphs like getTextWidths() and getTextPath(). diff --git a/site/user/api/SkCanvas_Reference.md b/site/user/api/SkCanvas_Reference.md index 83a24e671f..4188be2783 100644 --- a/site/user/api/SkCanvas_Reference.md +++ b/site/user/api/SkCanvas_Reference.md @@ -436,14 +436,6 @@ SkCanvas member functions read and modify the structure properties. drawTextBlob draws text with arrays of positions and Paint - - drawTextOnPath - draws text following Path contour - - - drawTextOnPathHV - draws text following Path with offsets - drawTextRSXform draws text with array of RSXform @@ -5808,14 +5800,6 @@ are scaled if needed to take up the remaining space; the center is transparent. drawTextBlob(const sk sp<SkTextBlob>& blob, SkScalar x, SkScalar y, const SkPaint& paint) - - drawTextOnPath - draws text following Path contour - - - drawTextOnPathHV - draws text following Path with offsets - drawTextRSXform draws text with array of RSXform @@ -5869,7 +5853,7 @@ filled 12 point black Glyphs. ### See Also -drawString[2] drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform +drawString[2] drawPosText drawPosTextH drawTextBlob[2] drawTextRSXform --- @@ -5918,7 +5902,7 @@ ending with a char value of zero ### See Also -drawText drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform +drawText drawPosText drawPosTextH drawTextBlob[2] drawTextRSXform --- @@ -5966,7 +5950,7 @@ ending with a char value of zero ### See Also -drawText drawPosText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform +drawText drawPosText drawPosTextH drawTextBlob[2] drawTextRSXform --- @@ -6015,7 +5999,7 @@ rather than using the font advance widths. ### See Also -drawText drawPosTextH drawTextBlob[2] drawTextOnPath drawTextRSXform +drawText drawPosTextH drawTextBlob[2] drawTextRSXform --- @@ -6070,7 +6054,7 @@ baseline. ### See Also -drawText drawPosText drawTextBlob[2] drawTextOnPath drawTextRSXform +drawText drawPosText drawTextBlob[2] drawTextRSXform --- @@ -6082,52 +6066,7 @@ void drawTextOnPathHV(const void* text, SkScalar vOffset, const SkPaint& paint) -Draws text on Path path, using Clip, Matrix, and Paint paint. - -Origin of text is at distance hOffset along the path, offset by a perpendicular -vector of length vOffset. If the path section corresponding the glyph advance is -curved, the glyph is drawn curved to match; control points in the glyph are -mapped to projected points parallel to the path. If the text advance is larger -than the path length, the excess text is clipped. - -text meaning depends on Paint Text Encoding; by default, text is encoded as -UTF-8. Origin meaning depends on Paint Text Align and Paint Vertical Text; by -default text positions the first glyph left side bearing and baseline relative -to origin. Text size is affected by Matrix and Paint Text Size. - -All elements of paint: Path Effect, Mask Filter, Shader, -Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws -filled 12 point black Glyphs. - -### Parameters - - - - - - - - - - - - - - - - - - - -
textcharacter code points or Glyphs drawn
byteLengthbyte length of text array
pathPath providing text baseline
hOffsetdistance along path to offset origin
vOffsetoffset of text above (if negative) or below (if positive) the path
painttext size, blend, color, and so on, used to draw
- -### Example - -
- -### See Also - -drawTextOnPath drawText drawPosTextH drawTextBlob[2] drawTextRSXform +Deprecated. --- @@ -6139,53 +6078,7 @@ void drawTextOnPath(const void* text, siz const SkPaint& paint) -Draws text on Path path, using Clip, Matrix, and Paint paint. - -Origin of text is at beginning of path offset by matrix, if not nullptr. -matrix transforms text before text is mapped to path. If the path section -corresponding the glyph advance is curved, the glyph is drawn curved to match; -control points in the glyph are mapped to projected points parallel to the path. -If the text advance is larger than the path length, the excess text is clipped. - -matrix does not effect paint Shader. - -text meaning depends on Paint Text Encoding; by default, text is encoded as -UTF-8. Origin meaning depends on Paint Text Align and Paint Vertical Text; by -default text positions the first glyph left side bearing and baseline relative -to origin. Text size is affected by matrix parameter, Canvas Matrix, -and Paint Text Size. - -All elements of paint: Path Effect, Mask Filter, Shader, -Color Filter, Image Filter, and Draw Looper; apply to text. By default, draws -filled 12 point black Glyphs. - -### Parameters - - - - - - - - - - - - - - - - -
textcharacter code points or Glyphs drawn
byteLengthbyte length of text array
pathPath providing text baseline
matrixtransform of Glyphs before mapping to path; may be nullptr -to use identity Matrix
painttext size, blend, color, and so on, used to draw
- -### Example - -
- -### See Also - -drawTextOnPathHV drawText drawPosTextH drawTextBlob[2] drawTextRSXform +Deprecated. --- @@ -6235,7 +6128,7 @@ filled 12 point black Glyphs. ### See Also -drawTextOnPath drawTextOnPathHV drawText drawPosText drawTextBlob[2] +drawText drawPosText drawTextBlob[2] --- diff --git a/site/user/api/SkPaint_Reference.md b/site/user/api/SkPaint_Reference.md index 9603c5d46d..a8f4651260 100644 --- a/site/user/api/SkPaint_Reference.md +++ b/site/user/api/SkPaint_Reference.md @@ -4336,8 +4336,7 @@ Deprecated. Align adjusts the text relative to the text position. Align affects Glyphs drawn with: SkCanvas::drawText, SkCanvas::drawPosText, -SkCanvas::drawPosTextH, SkCanvas::drawTextOnPath, -SkCanvas::drawTextOnPathHV, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, +SkCanvas::drawPosTextH, SkCanvas::drawTextRSXform, SkCanvas::drawTextBlob, and SkCanvas::drawString; as well as calls that place text Glyphs like getTextWidths and getTextPath. diff --git a/site/user/api/SkPath_Reference.md b/site/user/api/SkPath_Reference.md index d78cee9bd9..357db3054c 100644 --- a/site/user/api/SkPath_Reference.md +++ b/site/user/api/SkPath_Reference.md @@ -3684,9 +3684,7 @@ so additional values choose a single solution. This construction is similar to < conicTo can represent any Arc with a sweep less than 180 degrees at any rotation. All arcTo constructions are converted to Conic data when added to Path. -### Example - -
+![Arc](https://fiddle.skia.org/i/fe909570a3c42269b447b061158177b9_raster.png "") @@ -3702,17 +3700,26 @@ Direction sweep, SkScalar x, SkScalar y)
1 arcTo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool forceMoveTo)
-
- ### Example -
1 describes an arc from an oval, a starting angle, and a sweep angle. -2 is similar to 1, but does not require building a path to draw. -3 is similar to 1, but always begins new Contour. -4 describes an arc from a pair of tangent lines and a radius. -5 describes an arc from Oval center, arc start Point and arc end Point. -6 describes an arc from a pair of tangent lines and a Conic Weight. -
+
+ +In the example above: + + + + + + + + + + + + + + +
1 describes an arc from an oval, a starting angle, and a sweep angle.
2 is similar to 1, but does not require building a path to draw.
3 is similar to 1, but always begins new Contour.
4 describes an arc from a pair of tangent lines and a radius.
5 describes an arc from Oval center, arc start Point and arc end Point.
6 describes an arc from a pair of tangent lines and a Conic Weight.
## arcTo @@ -4910,7 +4917,7 @@ reference to Path ### Example -
+
### See Also diff --git a/site/user/api/catalog.htm b/site/user/api/catalog.htm index 2313cfd2de..610aba1e9b 100644 --- a/site/user/api/catalog.htm +++ b/site/user/api/catalog.htm @@ -4001,6 +4001,14 @@ "hash": "fecfe58c25cfc1b1e411e5eb50f7d8d1", "file": "illustrations", "name": "Image_Info_Color_Type_RGB_888" +}, + "Illustrations_Path_Arc": { + "code": "#include \"SkTextOnPath.h\"\nstruct data {\n const char* name;\n char super;\n int yn[10];\n};\nconst data dataSet[] = {\n{ \"arcTo sweep\", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }},\n{ \"drawArc\", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }},\n{ \"addArc\", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }},\n{ \"arcTo tangents\", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"arcTo radii\", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"conicTo\", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }}\n};\n#define __degree_symbol__ \"\\xC2\" \"\\xB0\"\nconst char* headers[] = {\n \"Oval part\",\n \"force moveTo\",\n \"can draw 180\" __degree_symbol__,\n \"can draw 360\" __degree_symbol__,\n \"can draw greater than 360\" __degree_symbol__,\n \"ignored if radius is zero\",\n \"ignored if sweep is zero\",\n \"requires Path\",\n \"describes rotation\",\n \"describes perspective\",\n};\nconst char* yna[] = {\n \"n/a\",\n \"no\",\n \"yes\"\n};\n\nvoid draw(SkCanvas* canvas) {\n SkPaint lp;\n lp.setAntiAlias(true);\n SkPaint tp(lp);\n SkPaint sp(tp);\n SkPaint bp(tp);\n bp.setFakeBoldText(true);\n sp.setTextSize(10);\n lp.setColor(SK_ColorGRAY);\n canvas->translate(0, 32);\n const int tl = 115;\n for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) {\n canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp);\n if (0 == col) {\n continue;\n }\n canvas->drawLine(tl + col * 35, 100, tl + 100 + col * 35, 0, lp);\n SkPath path;\n path.moveTo(tl - 3 + col * 35, 103);\n path.lineTo(tl + 124 + col * 35, -24);\n SkMatrix matrix;\n matrix.setTranslate(0, -9);\n SkDrawTextOnPath(headers[col -1], strlen(headers[col -1]), bp, path, &matrix, canvas);\n }\n for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) {\n if (0 == row) {\n canvas->drawLine(tl, 100, tl + 350, 100, lp);\n } else {\n canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp);\n }\n if (row == SK_ARRAY_COUNT(dataSet)) {\n break;\n }\n canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp);\n if (dataSet[row].super) {\n SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name));\n canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp);\n }\n for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) {\n int val = dataSet[row].yn[col];\n canvas->drawString(yna[SkTMin(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp);\n if (val > 1) {\n char supe = '0' + val - 1;\n canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp);\n }\n }\n }\n}\n", + "width": 600, + "height": 300, + "hash": "fe909570a3c42269b447b061158177b9", + "file": "illustrations", + "name": "Path_Arc" }, "Image_Info_Alpha_Type_Opaque": { "code": "void draw(SkCanvas* canvas) {\n SkPMColor color = SkPreMultiplyARGB(255, 50, 100, 150);\n SkString s;\n s.printf(\"%u %u %u %u\", SkColorGetA(color), SkColorGetR(color),\n SkColorGetG(color), SkColorGetB(color));\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(s, 10, 62, paint);\n canvas->scale(50, 50);\n SkBitmap bitmap;\n SkImageInfo imageInfo = SkImageInfo::Make(1, 1, kN32_SkColorType, kOpaque_SkAlphaType);\n if (bitmap.installPixels(imageInfo, (void*) &color, imageInfo.minRowBytes())) {\n canvas->drawBitmap(bitmap, 0, 0);\n }\n}", @@ -4347,20 +4355,12 @@ "name": "Path" }, "Path_Arc": { - "code": "struct data {\n const char* name;\n char super;\n int yn[10];\n};\nconst data dataSet[] = {\n{ \"arcTo sweep\", '1', {1, 3, 1, 0, 0, 0, 0, 1, 0, 0 }},\n{ \"drawArc\", 0, {1, -1, 1, 1, 1, 1, 1, 0, 0, 0 }},\n{ \"addArc\", 0, {1, 1, 1, 4, 0, 1, 1, 1, 0, 0 }},\n{ \"arcTo tangents\", '4', {0, 0, 0, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"arcTo radii\", '5', {1, 0, 1, 0, 0, 0, 0, 1, 1, 0 }},\n{ \"conicTo\", 0, {1, 1, 0, 0, 0, 0, 0, 1, 1, 1 }}\n};\n#define __degree_symbol__ \"\\xC2\" \"\\xB0\"\nconst char* headers[] = {\n \"Oval part\",\n \"force moveTo\",\n \"can draw 180\" __degree_symbol__,\n \"can draw 360\" __degree_symbol__,\n \"can draw greater than 360\" __degree_symbol__,\n \"ignored if radius is zero\",\n \"ignored if sweep is zero\",\n \"requires Path\",\n \"describes rotation\",\n \"describes perspective\",\n};\nconst char* yna[] = {\n \"n/a\",\n \"no\",\n \"yes\"\n};\n\nvoid draw(SkCanvas* canvas) {\n SkPaint lp;\n lp.setAntiAlias(true);\n SkPaint tp(lp);\n SkPaint sp(tp);\n SkPaint bp(tp);\n bp.setFakeBoldText(true);\n sp.setTextSize(10);\n lp.setColor(SK_ColorGRAY);\n canvas->translate(0, 32);\n const int tl = 115;\n for (unsigned col = 0; col <= SK_ARRAY_COUNT(headers); ++col) {\n canvas->drawLine(tl + col * 35, 100, tl + col * 35, 250, lp);\n if (0 == col) {\n continue;\n }\n canvas->drawLine(tl + col * 35, 100, tl + 100 + col * 35, 0, lp);\n SkPath path;\n path.moveTo(tl - 3 + col * 35, 103);\n path.lineTo(tl + 124 + col * 35, -24);\n canvas->drawTextOnPathHV(headers[col -1], strlen(headers[col -1]), path, 0, -9, bp);\n }\n for (unsigned row = 0; row <= SK_ARRAY_COUNT(dataSet); ++row) {\n if (0 == row) {\n canvas->drawLine(tl, 100, tl + 350, 100, lp);\n } else {\n canvas->drawLine(5, 100 + row * 25, tl + 350, 100 + row * 25, lp);\n }\n if (row == SK_ARRAY_COUNT(dataSet)) {\n break;\n }\n canvas->drawString(dataSet[row].name, 5, 117 + row * 25, bp);\n if (dataSet[row].super) {\n SkScalar width = bp.measureText(dataSet[row].name, strlen(dataSet[row].name));\n canvas->drawText(&dataSet[row].super, 1, 8 + width, 112 + row * 25, sp);\n }\n for (unsigned col = 0; col < SK_ARRAY_COUNT(headers); ++col) {\n int val = dataSet[row].yn[col];\n canvas->drawString(yna[SkTMin(2, val + 1)], tl + 5 + col * 35, 117 + row * 25, tp);\n if (val > 1) {\n char supe = '0' + val - 1;\n canvas->drawText(&supe, 1, tl + 25 + col * 35, 112 + row * 25, sp);\n }\n }\n }\n}\n", - "width": 600, - "height": 300, - "hash": "891ac93abd0cdb27c4156685d3b1bb4c", - "file": "SkPath_Reference", - "name": "Arc" -}, - "Path_Arc_a": { "code": "void draw(SkCanvas* canvas) {\n SkRect oval = {8, 8, 56, 56};\n SkPaint ovalPaint;\n ovalPaint.setAntiAlias(true);\n SkPaint textPaint(ovalPaint);\n ovalPaint.setStyle(SkPaint::kStroke_Style);\n SkPaint arcPaint(ovalPaint);\n arcPaint.setStrokeWidth(5);\n arcPaint.setColor(SK_ColorBLUE);\n canvas->translate(-64, 0);\n for (char arcStyle = '1'; arcStyle <= '6'; ++arcStyle) {\n '4' == arcStyle ? canvas->translate(-96, 55) : canvas->translate(64, 0);\n canvas->drawText(&arcStyle, 1, 30, 36, textPaint);\n canvas->drawOval(oval, ovalPaint);\n SkPath path;\n path.moveTo({56, 32});\n switch (arcStyle) {\n case '1':\n path.arcTo(oval, 0, 90, false);\n break;\n case '2':\n canvas->drawArc(oval, 0, 90, false, arcPaint);\n continue;\n case '3':\n path.addArc(oval, 0, 90);\n break;\n case '4':\n path.arcTo({56, 56}, {32, 56}, 24);\n break;\n case '5':\n path.arcTo({24, 24}, 0, SkPath::kSmall_ArcSize, SkPath::kCW_Direction, {32, 56});\n break;\n case '6':\n path.conicTo({56, 56}, {32, 56}, SK_ScalarRoot2Over2);\n break;\n }\n canvas->drawPath(path, arcPaint);\n }\n}\n", "width": 256, "height": 128, "hash": "5acc77eba0cb4d00bbf3a8f4db0c0aee", "file": "SkPath_Reference", - "name": "Arc_2" + "name": "Arc" }, "Path_Contour": { "code": "void draw(SkCanvas* canvas) {\n SkPaint paint;\n paint.setAntiAlias(true);\n canvas->drawString(\"1st contour\", 150, 100, paint);\n canvas->drawString(\"2nd contour\", 130, 160, paint);\n canvas->drawString(\"3rd contour\", 40, 30, paint);\n paint.setStyle(SkPaint::kStroke_Style);\n SkPath path;\n path.moveTo(124, 108);\n path.lineTo(172, 24);\n path.moveTo(36, 148);\n path.quadTo(66, 188, 120, 136);\n path.close();\n path.conicTo(70, 20, 110, 40, 0.6f);\n canvas->drawPath(path, paint);\n}", @@ -5313,22 +5313,6 @@ "hash": "af4c69fbbd165c8b0eb0c9bd49ccbd8d", "file": "SkCanvas_Reference", "name": "SkCanvas::drawTextBlob_2" -}, - "SkCanvas_drawTextOnPath": { - "code": "void draw(SkCanvas* canvas) {\n const char roller[] = \"rollercoaster\";\n const size_t len = sizeof(roller) - 1;\n SkPath path;\n path.cubicTo(40, -80, 120, 80, 160, -40);\n SkPaint paint;\n paint.setTextSize(32);\n paint.setStyle(SkPaint::kStroke_Style);\n SkMatrix matrix;\n matrix.setIdentity();\n for (int i = 0; i < 3; ++i) {\n canvas->translate(25, 60);\n canvas->drawPath(path, paint);\n canvas->drawTextOnPath(roller, len, path, &matrix, paint);\n matrix.preTranslate(0, 10);\n }\n}\n", - "width": 256, - "height": 256, - "hash": "236e680b27960ca22641586dba0599c9", - "file": "SkCanvas_Reference", - "name": "SkCanvas::drawTextOnPath" -}, - "SkCanvas_drawTextOnPathHV": { - "code": "void draw(SkCanvas* canvas) {\n const char aero[] = \"correo a\" \"\\xC3\" \"\\xA9\" \"reo\";\n const size_t len = sizeof(aero) - 1;\n SkPath path;\n path.addOval({43-26, 43-26, 43+26, 43+26}, SkPath::kCW_Direction, 3);\n SkPaint paint;\n paint.setTextSize(24);\n for (auto offset : { 0, 10, 20 } ) {\n canvas->drawTextOnPathHV(aero, len, path, 0, -offset, paint);\n canvas->translate(70 + offset, 70 + offset);\n }\n}\n", - "width": 256, - "height": 256, - "hash": "b2f22d1d5041e55d6913aab52f73a7d3", - "file": "SkCanvas_Reference", - "name": "SkCanvas::drawTextOnPathHV" }, "SkCanvas_drawTextRSXform": { "code": "void draw(SkCanvas* canvas) {\n const int iterations = 26;\n SkRSXform transforms[iterations];\n char alphabet[iterations];\n SkScalar angle = 0;\n SkScalar scale = 1;\n for (size_t i = 0; i < SK_ARRAY_COUNT(transforms); ++i) {\n const SkScalar s = SkScalarSin(angle) * scale;\n const SkScalar c = SkScalarCos(angle) * scale;\n transforms[i] = SkRSXform::Make(-c, -s, -s * 16, c * 16);\n angle += .45;\n scale += .2;\n alphabet[i] = 'A' + i;\n }\n SkPaint paint;\n paint.setTextAlign(SkPaint::kCenter_Align);\n canvas->translate(110, 138);\n canvas->drawTextRSXform(alphabet, sizeof(alphabet), transforms, nullptr, paint);\n}\n", @@ -7515,10 +7499,10 @@ "name": "SkPath::addRRect" }, "SkPath_addRRect_2": { - "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 canvas->drawTextOnPathHV(&\"01234567\"[start], 1, textPath, 0, -5, paint);\n }\n}\n", + "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", "width": 256, "height": 256, - "hash": "f18740ffcb10a499007488948c2cd60d", + "hash": "0e6ca92d854035da29e89ad81d85ff85", "file": "SkPath_Reference", "name": "SkPath::addRRect_2" },