| 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_interpolate, 256, 60, false, 0) { |
| 5 |
void draw(SkCanvas* canvas) { |
| 6 |
SkPaint paint; |
| 7 |
paint.setAntiAlias(true); |
| 8 |
paint.setStyle(SkPaint::kStroke_Style); |
| 9 |
SkPath path, path2; |
| 10 |
path = SkPathBuilder() |
| 11 |
.moveTo(20, 20) |
| 12 |
.lineTo(40, 40) |
| 13 |
.lineTo(20, 40) |
| 14 |
.lineTo(40, 20) |
| 15 |
.close() |
| 16 |
.detach(); |
| 17 |
path2 = SkPath::Rect({20, 20, 40, 40}); |
| 18 |
for (SkScalar i = 0; i <= 1; i += 1.f / 6) { |
| 19 |
SkPath interp; |
| 20 |
path.interpolate(path2, i, &interp); |
| 21 |
canvas->drawPath(interp, paint); |
| 22 |
canvas->translate(30, 0); |
| 23 |
} |
| 24 |
} |
| 25 |
} // END FIDDLE |