Debian Codegraph @

docs/examples/Path_IsQuadDegenerate.cpp

raw
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_IsQuadDegenerate, 256, 256, true, 0) {
5 void draw(SkCanvas* canvas) {
6 auto debugster = [](const SkPath& path, bool exact) -> void {
7 SkDebugf("quad (%1.8g,%1.8g), (%1.8g,%1.8g), (%1.8g,%1.8g) is %s" "degenerate, %s\n",
8 path.getPoint(0).fX, path.getPoint(0).fY, path.getPoint(1).fX,
9 path.getPoint(1).fY, path.getPoint(2).fX, path.getPoint(2).fY,
10 SkPath::IsQuadDegenerate(path.getPoint(0), path.getPoint(1), path.getPoint(2), exact) ?
11 "" : "not ", exact ? "exactly" : "nearly");
12 };
13 SkPath path = SkPathBuilder()
14 .moveTo({100, 100})
15 .quadTo({100.00001f, 100.00001f}, {100.00002f, 100.00002f})
16 .detach();
17 SkPath offset = path.makeOffset(1000, 1000);
18 for (bool exact : { false, true } ) {
19 debugster(path, exact);
20 debugster(offset, exact);
21 }
22 }
23 } // END FIDDLE