diff options
author | Chris Dalton <csmartdalton@google.com> | 2017-11-06 14:10:54 -0700 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-11-07 01:51:31 +0000 |
commit | 7c02cc7934d08da3217ff9a0baae72cb93b09c6b (patch) | |
tree | 8f6ff7a992a2bddbfd0c28bfad74572aa17feb90 /tools/sk_tool_utils.cpp | |
parent | 61ffd53a906524836e2704b89637cceb487da76c (diff) |
Add clipping options to path text bench and samples
Bug: skia:
Change-Id: I632a2fa5627ef1438d9ab451318a42d12c61b802
Reviewed-on: https://skia-review.googlesource.com/67683
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Chris Dalton <csmartdalton@google.com>
Diffstat (limited to 'tools/sk_tool_utils.cpp')
-rw-r--r-- | tools/sk_tool_utils.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/sk_tool_utils.cpp b/tools/sk_tool_utils.cpp index 0a93db4239..56c1f48ed9 100644 --- a/tools/sk_tool_utils.cpp +++ b/tools/sk_tool_utils.cpp @@ -263,6 +263,21 @@ void add_to_text_blob(SkTextBlobBuilder* builder, const char* text, add_to_text_blob_w_len(builder, text, strlen(text), origPaint, x, y); } +SkPath make_star(const SkRect& bounds, int numPts, int step) { + SkPath path; + path.setFillType(SkPath::kEvenOdd_FillType); + path.moveTo(0,-1); + for (int i = 1; i < numPts; ++i) { + int idx = i*step; + SkScalar theta = idx * 2*SK_ScalarPI/numPts + SK_ScalarPI/2; + SkScalar x = SkScalarCos(theta); + SkScalar y = -SkScalarSin(theta); + path.lineTo(x, y); + } + path.transform(SkMatrix::MakeRectToRect(path.getBounds(), bounds, SkMatrix::kFill_ScaleToFit)); + return path; +} + #if !defined(__clang__) && defined(_MSC_VER) // MSVC takes ~2 minutes to compile this function with optimization. // We don't really care to wait that long for this function. |