blob: 5e1e7d583e860ab351be927c802ba5e5e54d8d9e [file] [log] [blame]
Hal Canary87515122019-03-15 14:22:51 -04001#if 0 // Disabled until updated to use current API.
2// Copyright 2019 Google LLC.
3// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Mike Kleinc0bd9f92019-04-23 12:05:21 -05004#include "tools/fiddle/examples.h"
Hal Canary87515122019-03-15 14:22:51 -04005// HASH=17c3070b31b700ea8f52e48af9a66b6e
Hal Canarya7181e7c2019-03-18 16:06:34 -04006REG_FIDDLE(Matrix_ScaleToFit, 256, 256, false, 0) {
Hal Canary87515122019-03-15 14:22:51 -04007void draw(SkCanvas* canvas) {
8 const char* labels[] = { "Fill", "Start", "Center", "End" };
9 SkRect rects[] = {{5, 5, 59, 59}, {5, 74, 59, 108}, {10, 123, 44, 172}, {10, 187, 54, 231}};
10 SkRect bounds;
11 source.getBounds(&bounds);
12 SkPaint paint;
13 paint.setAntiAlias(true);
14 for (auto fit : { SkMatrix::kFill_ScaleToFit, SkMatrix::kStart_ScaleToFit,
15 SkMatrix::kCenter_ScaleToFit, SkMatrix::kEnd_ScaleToFit } ) {
16 for (auto rect : rects ) {
17 canvas->drawRect(rect, paint);
18 SkMatrix matrix;
19 if (!matrix.setRectToRect(bounds, rect, fit)) {
20 continue;
21 }
22 SkAutoCanvasRestore acr(canvas, true);
23 canvas->concat(matrix);
24 canvas->drawBitmap(source, 0, 0);
25 }
26 canvas->drawString(labels[fit], 10, 255, paint);
27 canvas->translate(64, 0);
28 }
29}
30} // END FIDDLE
31#endif // Disabled until updated to use current API.