Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
crbug_938592.cpp File Reference
#include "gm/gm.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkColor.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPoint.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkTileMode.h"
#include "include/effects/SkGradientShader.h"

Go to the source code of this file.

Functions

 DEF_SIMPLE_GM (crbug_938592, canvas, 500, 300)
 

Function Documentation

◆ DEF_SIMPLE_GM()

DEF_SIMPLE_GM ( crbug_938592  ,
canvas  ,
500  ,
300   
)

Definition at line 23 of file crbug_938592.cpp.

23 {
24 static constexpr SkPoint pts[] = {{0, 0}, {0, 30}};
25 static constexpr SkScalar pos[] = {0.f, 9.f / 20, 9.f / 20, 11.f / 20, 11.f / 20, 20.f / 20};
26 static constexpr SkColor c0 = SK_ColorBLUE;
27 static constexpr SkColor c1 = SK_ColorRED;
28 static constexpr SkColor c2 = SK_ColorGREEN;
29 static constexpr SkColor colors[] = {c0, c0, c1, c1, c2, c2};
30 auto grad = SkGradientShader::MakeLinear(pts, colors, pos, 6, SkTileMode::kClamp);
32 paint.setShader(grad);
33 static constexpr int kMirrorX = 400;
34 static constexpr int kMirrorY = 200;
35 canvas->translate(50, 50);
36 for (int i = 0; i < 4; ++i) {
37 canvas->save();
38 if (i & 0b01) {
39 canvas->translate(0, kMirrorY);
40 canvas->scale(1.f, -1.f);
41 }
42 if (i & 0b10) {
43 canvas->translate(kMirrorX, 0);
44 canvas->scale(-1.f, 1.f);
45 }
46 canvas->drawRect({0, 0, 150, 30}, paint);
47 canvas->restore();
48 }
49}
SkPoint pos
uint32_t SkColor
Definition SkColor.h:37
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
const Paint & paint
float SkScalar
Definition extension.cpp:12
PODArray< SkColor > colors
Definition SkRecords.h:276