Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 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. |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 3 | #include "tools/fiddle/examples.h" |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 4 | // HASH=0e03cd9f154603ed4b21ca56d69dae44 |
Hal Canary | a7181e7c | 2019-03-18 16:06:34 -0400 | [diff] [blame] | 5 | REG_FIDDLE(Matrix_invert, 256, 128, false, 0) { |
Hal Canary | 8751512 | 2019-03-15 14:22:51 -0400 | [diff] [blame] | 6 | void draw(SkCanvas* canvas) { |
| 7 | const SkPoint src[] = { { 10, 120}, {120, 120}, {120, 10}, { 10, 10} }; |
| 8 | const SkPoint dst[] = { {150, 120}, {200, 100}, {240, 30}, { 130, 40} }; |
| 9 | SkPaint paint; |
| 10 | paint.setAntiAlias(true); |
| 11 | SkMatrix matrix; |
| 12 | matrix.setPolyToPoly(src, dst, 4); |
| 13 | canvas->drawPoints(SkCanvas::kPolygon_PointMode, 4, src, paint); |
| 14 | canvas->drawPoints(SkCanvas::kPolygon_PointMode, 4, dst, paint); |
| 15 | paint.setColor(SK_ColorBLUE); |
| 16 | paint.setStrokeWidth(3); |
| 17 | paint.setStrokeCap(SkPaint::kRound_Cap); |
| 18 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, dst, paint); |
| 19 | if (matrix.invert(&matrix)) { |
| 20 | canvas->concat(matrix); |
| 21 | canvas->drawPoints(SkCanvas::kPoints_PointMode, 4, dst, paint); |
| 22 | } |
| 23 | } |
| 24 | } // END FIDDLE |