| 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) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkPath path = SkPath::RRect({10, 20, 54, 120}, 10, 20); |
| 7 |
SkRect tests[] = { |
| 8 |
{ 10, 40, 54, 80 }, |
| 9 |
{ 25, 20, 39, 120 }, |
| 10 |
{ 15, 25, 49, 115 }, |
| 11 |
{ 13, 27, 51, 113 }, |
| 12 |
}; |
| 13 |
for (unsigned i = 0; i < std::size(tests); ++i) { |
| 14 |
SkPaint paint; |
| 15 |
paint.setColor(SK_ColorRED); |
| 16 |
canvas->drawPath(path, paint); |
| 17 |
bool rectInPath = path.conservativelyContainsRect(tests[i]); |
| 18 |
paint.setColor(rectInPath ? SK_ColorBLUE : SK_ColorBLACK); |
| 19 |
canvas->drawRect(tests[i], paint); |
| 20 |
canvas->translate(64, 0); |
| 21 |
} |
| 22 |
} |
| 23 |
} // END FIDDLE |