Flutter Engine
The Flutter Engine
Functions
drawlines_with_local_matrix.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/effects/SkGradientShader.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (drawlines_with_local_matrix, canvas, 500, 500)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( drawlines_with_local_matrix  ,
canvas  ,
500  ,
500   
)

Definition at line 13 of file drawlines_with_local_matrix.cpp.

13 {
14 canvas->clipRect({0,0,500,500});
15 SkPaint grad;
16 grad.setAntiAlias(true);
18 float pos[6] = {0, 2/6.f, 3/6.f, 4/6.f, 5/6.f, 1};
19 constexpr SkColor indigo = SkColorSetARGB(0xFF, 0x4b, 0x00, 0x82);
20 constexpr SkColor violet = SkColorSetARGB(0xFF, 0xee, 0x82, 0xee);
23 canvas->drawPaint(grad);
24
25 SkPaint white;
26 white.setAntiAlias(true);
29
30 auto drawLine = [&](float x0, float y0, float x1, float y1, float w) {
31 SkPoint p[2] = {{x0, y0}, {x1, y1}};
32 white.setStrokeWidth(w);
33 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, p, white);
34 grad.setStrokeWidth(w - 4);
35 canvas->drawPoints(SkCanvas::kLines_PointMode, 2, p, grad);
36 };
37
38 drawLine(20, 20, 200, 120, 20);
39 drawLine(20, 200, 20, 100, 20);
40 drawLine(480, 20, 400, 400, 20);
41 drawLine(50, 480, 260, 100, 20);
42 drawLine(270, 20, 380, 210, 20);
43 drawLine(280, 280, 400, 480, 20);
44 drawLine(160, 375, 280, 375, 20);
45 drawLine(220, 410, 220, 470, 20);
46 drawLine(250, 250, 250, 250, 20);
47}
SkPoint pos
constexpr SkColor SK_ColorYELLOW
Definition: SkColor.h:139
uint32_t SkColor
Definition: SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition: SkColor.h:135
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
static constexpr SkColor SkColorSetARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Definition: SkColor.h:49
constexpr SkColor SK_ColorGREEN
Definition: SkColor.h:131
constexpr SkColor SK_ColorWHITE
Definition: SkColor.h:122
@ kLines_PointMode
draw each pair of points as a line segment
Definition: SkCanvas.h:1242
static sk_sp< SkShader > MakeRadial(const SkPoint &center, SkScalar radius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
void setColor(SkColor color)
Definition: SkPaint.cpp:119
void setAntiAlias(bool aa)
Definition: SkPaint.h:170
void setStrokeCap(Cap cap)
Definition: SkPaint.cpp:179
void setShader(sk_sp< SkShader > shader)
void setStrokeWidth(SkScalar width)
Definition: SkPaint.cpp:159
PODArray< SkColor > colors
Definition: SkRecords.h:276
SkScalar w