xref: /third_party/skia/docs/examples/getLocalBounds_working.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/docs/examples/
1cb93a386Sopenharmony_ci// Copyright 2020 Google LLC.
2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h"
4cb93a386Sopenharmony_ciREG_FIDDLE(getLocalBounds_working, 256, 256, true, 0) {
5cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
6cb93a386Sopenharmony_ci    SkCanvas local(256, 256);
7cb93a386Sopenharmony_ci    canvas = &local;
8cb93a386Sopenharmony_ci    SkRect bounds = canvas->getLocalClipBounds();
9cb93a386Sopenharmony_ci    SkDebugf("left:%g  top:%g  right:%g  bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight,
10cb93a386Sopenharmony_ci             bounds.fBottom);
11cb93a386Sopenharmony_ci    SkPoint clipPoints[] = {{30, 130}, {120, 130}, {120, 230}};
12cb93a386Sopenharmony_ci    SkPath clipPath;
13cb93a386Sopenharmony_ci    clipPath.addPoly(clipPoints, SK_ARRAY_COUNT(clipPoints), true);
14cb93a386Sopenharmony_ci    canvas->clipPath(clipPath);
15cb93a386Sopenharmony_ci    bounds = canvas->getLocalClipBounds();
16cb93a386Sopenharmony_ci    SkDebugf("left:%g  top:%g  right:%g  bottom:%g\n", bounds.fLeft, bounds.fTop, bounds.fRight,
17cb93a386Sopenharmony_ci             bounds.fBottom);
18cb93a386Sopenharmony_ci}
19cb93a386Sopenharmony_ci}  // END FIDDLE
20

Indexes created Thu Nov 07 10:32:03 CST 2024