diff options
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. |