Flutter Engine
The Flutter Engine
Functions
mapradius.cpp File Reference
#include "tools/fiddle/examples.h"

Go to the source code of this file.

Functions

 REG_FIDDLE (mapradius, 256, 256, false, 0)
 

Function Documentation

◆ REG_FIDDLE()

REG_FIDDLE ( mapradius  ,
256  ,
256  ,
false  ,
 
)

Definition at line 4 of file mapradius.cpp.

4 {
5void draw(SkCanvas* canvas) {
7 paint.setAntiAlias(true);
10 const SkPoint center = {128, 103};
11 matrix.setScale(2, .5f, center.fX, center.fY);
12 matrix.postRotate(45, center.fX, center.fY);
13 const SkScalar circleRadius = 60;
14 SkScalar mappedRadius = matrix.mapRadius(circleRadius);
15 SkVector minorAxis, majorAxis;
16 matrix.mapVector(0, circleRadius, &minorAxis);
17 matrix.mapVector(circleRadius, 0, &majorAxis);
18 paint.setColor(SK_ColorRED);
19 canvas->drawLine(40, 240, 40 + minorAxis.length(), 240, paint);
20 canvas->drawLine(42 + minorAxis.length(), 240, 42 + minorAxis.length() + majorAxis.length(),
21 240, paint);
22 paint.setColor(SK_ColorBLACK);
23 canvas->drawLine(center.fX, center.fY, center.fX + mappedRadius, center.fY, paint);
24 canvas->drawLine(center.fX, center.fY, center.fX, center.fY + mappedRadius, paint);
25 canvas->drawLine(40, 220, 40 + mappedRadius, 220, paint);
26 canvas->drawLine(42 + mappedRadius, 220, 42 + mappedRadius * 2, 220, paint);
27 canvas->concat(matrix);
28 canvas->drawCircle(center.fX, center.fY, circleRadius, paint);
29 paint.setColor(SK_ColorRED);
30 canvas->drawLine(center.fX, center.fY, center.fX + circleRadius, center.fY, paint);
31 canvas->drawLine(center.fX, center.fY, center.fX, center.fY + circleRadius, paint);
32}
33} // END FIDDLE
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
constexpr SkColor SK_ColorBLACK
Definition: SkColor.h:103
static SkScalar center(float pos0, float pos1)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
Definition: aaclip.cpp:27
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
Definition: SkCanvas.cpp:2700
void concat(const SkMatrix &matrix)
Definition: SkCanvas.cpp:1318
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
Definition: SkCanvas.cpp:2707
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
const Paint & paint
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
float length() const
Definition: SkPoint_impl.h:282