xref: /third_party/skia/docs/examples/Path_interpolate.cpp (revision cb93a386)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/skia/docs/examples/
1cb93a386Sopenharmony_ci// Copyright 2019 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_ci// HASH=404f11c5c9c9ca8a64822d484552a473
5cb93a386Sopenharmony_ciREG_FIDDLE(Path_interpolate, 256, 60, false, 0) {
6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) {
7cb93a386Sopenharmony_ci    SkPaint paint;
8cb93a386Sopenharmony_ci    paint.setAntiAlias(true);
9cb93a386Sopenharmony_ci    paint.setStyle(SkPaint::kStroke_Style);
10cb93a386Sopenharmony_ci    SkPath path, path2;
11cb93a386Sopenharmony_ci    path.moveTo(20, 20);
12cb93a386Sopenharmony_ci    path.lineTo(40, 40);
13cb93a386Sopenharmony_ci    path.lineTo(20, 40);
14cb93a386Sopenharmony_ci    path.lineTo(40, 20);
15cb93a386Sopenharmony_ci    path.close();
16cb93a386Sopenharmony_ci    path2.addRect({20, 20, 40, 40});
17cb93a386Sopenharmony_ci    for (SkScalar i = 0; i <= 1; i += 1.f / 6) {
18cb93a386Sopenharmony_ci      SkPath interp;
19cb93a386Sopenharmony_ci      path.interpolate(path2, i, &interp);
20cb93a386Sopenharmony_ci      canvas->drawPath(interp, paint);
21cb93a386Sopenharmony_ci      canvas->translate(30, 0);
22cb93a386Sopenharmony_ci    }
23cb93a386Sopenharmony_ci}
24cb93a386Sopenharmony_ci}  // END FIDDLE
25

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