1 // Copyright 2019 Google LLC.
2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3 #include "tools/fiddle/examples.h"
4 REG_FIDDLE(Path_conservativelyContainsRect, 256, 140, false, 0) {
draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) {
6 SkPath path;
7 path.addRoundRect({10, 20, 54, 120}, 10, 20);
8 SkRect tests[] = {
9 { 10, 40, 54, 80 },
10 { 25, 20, 39, 120 },
11 { 15, 25, 49, 115 },
12 { 13, 27, 51, 113 },
13 };
14 for (unsigned i = 0; i < std::size(tests); ++i) {
15 SkPaint paint;
16 paint.setColor(SK_ColorRED);
17 canvas->drawPath(path, paint);
18 bool rectInPath = path.conservativelyContainsRect(tests[i]);
19 paint.setColor(rectInPath ? SK_ColorBLUE : SK_ColorBLACK);
20 canvas->drawRect(tests[i], paint);
21 canvas->translate(64, 0);
22 }
23 }
24 } // END FIDDLE
25