1 #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.
4 #include "tools/fiddle/examples.h"
5 // HASH=6d6f2082fcf59d9f02bfb1758b87db69
6 REG_FIDDLE(Matrix_mapRadius, 256, 256, false, 0) {
7 void draw(SkCanvas* canvas) {
8     SkPaint paint;
9     paint.setAntiAlias(true);
10     SkMatrix matrix;
11     const SkPoint center = {108, 93};
12     matrix.setScale(2, .5f, center.fX, center.fY);
13     matrix.postRotate(45, center.fX, center.fY);
14     const SkScalar circleRadius = 50;
15     SkScalar mappedRadius = matrix.mapRadius(circleRadius);
16     SkVector minorAxis, majorAxis;
17     matrix.mapVector(0, circleRadius, &minorAxis);
18     matrix.mapVector(circleRadius, 0, &majorAxis);
19     SkString mappedArea;
20     mappedArea.printf("area = %g", mappedRadius * mappedRadius);
21     canvas->drawString(mappedArea, 145, 250, paint);
22     canvas->drawString("mappedRadius", center.fX + mappedRadius + 3, center.fY, paint);
23     paint.setColor(SK_ColorRED);
24     SkString axArea;
25     axArea.printf("area = %g", majorAxis.length() * minorAxis.length());
26     paint.setStyle(SkPaint::kFill_Style);
27     canvas->drawString(axArea, 15, 250, paint);
28     paint.setStyle(SkPaint::kStroke_Style);
29     canvas->drawRect({10, 200, 10 + majorAxis.length(), 200 + minorAxis.length()}, paint);
30     paint.setColor(SK_ColorBLACK);
31     canvas->drawLine(center.fX, center.fY, center.fX + mappedRadius, center.fY, paint);
32     canvas->drawLine(center.fX, center.fY, center.fX, center.fY + mappedRadius, paint);
33     canvas->drawRect({140, 180, 140 + mappedRadius, 180 + mappedRadius}, paint);
34     canvas->concat(matrix);
35     canvas->drawCircle(center.fX, center.fY, circleRadius, paint);
36     paint.setColor(SK_ColorRED);
37     canvas->drawLine(center.fX, center.fY, center.fX + circleRadius, center.fY, paint);
38     canvas->drawLine(center.fX, center.fY, center.fX, center.fY + circleRadius, paint);
39 }
40 }  // END FIDDLE
41 #endif  // Disabled until updated to use current API.
42