skia2/docs/examples/Matrix_mapRadius.cpp
Mike Klein c0bd9f9fe5 rewrite includes to not need so much -Ifoo
Current strategy: everything from the top

Things to look at first are the manual changes:

   - added tools/rewrite_includes.py
   - removed -Idirectives from BUILD.gn
   - various compile.sh simplifications
   - tweak tools/embed_resources.py
   - update gn/find_headers.py to write paths from the top
   - update gn/gn_to_bp.py SkUserConfig.h layout
     so that #include "include/config/SkUserConfig.h" always
     gets the header we want.

No-Presubmit: true
Change-Id: I73a4b181654e0e38d229bc456c0d0854bae3363e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/209706
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
2019-04-24 16:27:11 +00:00

42 lines
2.0 KiB
C++

#if 0 // Disabled until updated to use current API.
// Copyright 2019 Google LLC.
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
#include "tools/fiddle/examples.h"
// HASH=6d6f2082fcf59d9f02bfb1758b87db69
REG_FIDDLE(Matrix_mapRadius, 256, 256, false, 0) {
void draw(SkCanvas* canvas) {
SkPaint paint;
paint.setAntiAlias(true);
SkMatrix matrix;
const SkPoint center = {108, 93};
matrix.setScale(2, .5f, center.fX, center.fY);
matrix.postRotate(45, center.fX, center.fY);
const SkScalar circleRadius = 50;
SkScalar mappedRadius = matrix.mapRadius(circleRadius);
SkVector minorAxis, majorAxis;
matrix.mapVector(0, circleRadius, &minorAxis);
matrix.mapVector(circleRadius, 0, &majorAxis);
SkString mappedArea;
mappedArea.printf("area = %g", mappedRadius * mappedRadius);
canvas->drawString(mappedArea, 145, 250, paint);
canvas->drawString("mappedRadius", center.fX + mappedRadius + 3, center.fY, paint);
paint.setColor(SK_ColorRED);
SkString axArea;
axArea.printf("area = %g", majorAxis.length() * minorAxis.length());
paint.setStyle(SkPaint::kFill_Style);
canvas->drawString(axArea, 15, 250, paint);
paint.setStyle(SkPaint::kStroke_Style);
canvas->drawRect({10, 200, 10 + majorAxis.length(), 200 + minorAxis.length()}, paint);
paint.setColor(SK_ColorBLACK);
canvas->drawLine(center.fX, center.fY, center.fX + mappedRadius, center.fY, paint);
canvas->drawLine(center.fX, center.fY, center.fX, center.fY + mappedRadius, paint);
canvas->drawRect({140, 180, 140 + mappedRadius, 180 + mappedRadius}, paint);
canvas->concat(matrix);
canvas->drawCircle(center.fX, center.fY, circleRadius, paint);
paint.setColor(SK_ColorRED);
canvas->drawLine(center.fX, center.fY, center.fX + circleRadius, center.fY, paint);
canvas->drawLine(center.fX, center.fY, center.fX, center.fY + circleRadius, paint);
}
} // END FIDDLE
#endif // Disabled until updated to use current API.