Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
gradients_no_texture.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/SkRect.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkScalar.h"
#include "include/core/SkShader.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/core/SkTileMode.h"
#include "include/core/SkTypes.h"
#include "include/effects/SkGradientShader.h"
#include <string.h>

Go to the source code of this file.

Classes

struct  GradData
 
class  GradientsNoTextureGM
 
struct  ColorPos
 
class  GradientsManyColorsGM
 

Typedefs

typedef sk_sp< SkShader >(* GradMaker) (const SkPoint pts[2], const GradData &data, SkTileMode tm)
 

Functions

static sk_sp< SkShaderMakeLinear (const SkPoint pts[2], const GradData &data, SkTileMode tm)
 
static sk_sp< SkShaderMakeRadial (const SkPoint pts[2], const GradData &data, SkTileMode tm)
 
static sk_sp< SkShaderMakeSweep (const SkPoint pts[2], const GradData &data, SkTileMode)
 
static sk_sp< SkShaderMake2Radial (const SkPoint pts[2], const GradData &data, SkTileMode tm)
 
static sk_sp< SkShaderMake2Conical (const SkPoint pts[2], const GradData &data, SkTileMode tm)
 
static void make0 (ColorPos *rec)
 
static void make1 (ColorPos *rec)
 
static void make2 (ColorPos *rec)
 
static void make3 (ColorPos *rec)
 

Variables

constexpr SkColor gColors []
 
constexpr GradData gGradData []
 
constexpr GradMaker gGradMakers []
 

Typedef Documentation

◆ GradMaker

typedef sk_sp< SkShader >(* GradMaker) (const SkPoint pts[2], const GradData &data, SkTileMode tm)

Definition at line 87 of file gradients_no_texture.cpp.

Function Documentation

◆ make0()

static void make0 ( ColorPos rec)
static

Definition at line 166 of file gradients_no_texture.cpp.

166 {
167#if 0
168 From http://jsfiddle.net/3fe2a/
169
170background-image: -webkit-linear-gradient(left, #22d1cd 1%, #22d1cd 0.9510157507590116%, #df4b37 2.9510157507590113%, #df4b37 23.695886056604927%, #22d1cd 25.695886056604927%, #22d1cd 25.39321881940624%, #e6de36 27.39321881940624%, #e6de36 31.849399922570655%, #3267ff 33.849399922570655%, #3267ff 44.57735802921938%, #9d47d1 46.57735802921938%, #9d47d1 53.27185850805876%, #3267ff 55.27185850805876%, #3267ff 61.95718972227316%, #5cdd9d 63.95718972227316%, #5cdd9d 69.89166004442%, #3267ff 71.89166004442%, #3267ff 74.45795382765857%, #9d47d1 76.45795382765857%, #9d47d1 82.78364610713776%, #3267ff 84.78364610713776%, #3267ff 94.52743647737229%, #e3d082 96.52743647737229%, #e3d082 96.03934633331295%);
171height: 30px;
172#endif
173
174 const SkColor colors[] = {
175 0xFF22d1cd, 0xFF22d1cd, 0xFFdf4b37, 0xFFdf4b37, 0xFF22d1cd, 0xFF22d1cd, 0xFFe6de36, 0xFFe6de36,
176 0xFF3267ff, 0xFF3267ff, 0xFF9d47d1, 0xFF9d47d1, 0xFF3267ff, 0xFF3267ff, 0xFF5cdd9d, 0xFF5cdd9d,
177 0xFF3267ff, 0xFF3267ff, 0xFF9d47d1, 0xFF9d47d1, 0xFF3267ff, 0xFF3267ff, 0xFFe3d082, 0xFFe3d082
178 };
179 const double percent[] = {
180 1, 0.9510157507590116, 2.9510157507590113, 23.695886056604927,
181 25.695886056604927, 25.39321881940624, 27.39321881940624, 31.849399922570655,
182 33.849399922570655, 44.57735802921938, 46.57735802921938, 53.27185850805876,
183 55.27185850805876, 61.95718972227316, 63.95718972227316, 69.89166004442,
184 71.89166004442, 74.45795382765857, 76.45795382765857, 82.78364610713776,
185 84.78364610713776, 94.52743647737229, 96.52743647737229, 96.03934633331295,
186 };
187 const int N = std::size(percent);
188 SkScalar pos[N];
189 for (int i = 0; i < N; ++i) {
190 pos[i] = SkDoubleToScalar(percent[i] / 100);
191 }
192 rec->construct(colors, pos, N);
193}
SkPoint pos
uint32_t SkColor
Definition SkColor.h:37
static bool left(const SkPoint &p0, const SkPoint &p1)
#define SkDoubleToScalar(x)
Definition SkScalar.h:64
#define N
Definition beziers.cpp:19
sk_sp< SkImage > image
Definition examples.cpp:29
float SkScalar
Definition extension.cpp:12
PODArray< SkColor > colors
Definition SkRecords.h:276
int32_t height
void construct(const SkColor colors[], const SkScalar pos[], int count)
static sk_sp< SkShader > linear(sk_sp< SkShader > shader)

◆ make1()

static void make1 ( ColorPos rec)
static

Definition at line 195 of file gradients_no_texture.cpp.

195 {
196 const SkColor colors[] = {
200 };
201 rec->construct(colors, nullptr, std::size(colors));
202}
constexpr SkColor SK_ColorBLACK
Definition SkColor.h:103
constexpr SkColor SK_ColorWHITE
Definition SkColor.h:122

◆ make2()

static void make2 ( ColorPos rec)
static

Definition at line 204 of file gradients_no_texture.cpp.

204 {
205 const SkColor colors[] = {
209 };
210 const int N = std::size(colors);
211 SkScalar pos[N];
212 for (int i = 0; i < N; ++i) {
213 pos[i] = SK_Scalar1 * i / (N - 1);
214 }
215 rec->construct(colors, pos, N);
216}
#define SK_Scalar1
Definition SkScalar.h:18

◆ Make2Conical()

static sk_sp< SkShader > Make2Conical ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm 
)
static

Definition at line 74 of file gradients_no_texture.cpp.

74 {
75 SkPoint center0, center1;
76 SkScalar radius0 = (pts[1].fX - pts[0].fX) / 10;
77 SkScalar radius1 = (pts[1].fX - pts[0].fX) / 3;
78 center0.set(pts[0].fX + radius0, pts[0].fY + radius0);
79 center1.set(pts[1].fX - radius1, pts[1].fY - radius1);
80 return SkGradientShader::MakeTwoPointConical(center1, radius1,
81 center0, radius0,
82 data.fColors, data.fPos,
83 data.fCount, tm);
84}
static sk_sp< SkShader > MakeTwoPointConical(const SkPoint &start, SkScalar startRadius, const SkPoint &end, SkScalar endRadius, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41
float fX
x-axis value
void set(float x, float y)

◆ Make2Radial()

static sk_sp< SkShader > Make2Radial ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm 
)
static

Definition at line 62 of file gradients_no_texture.cpp.

62 {
63 SkPoint center0, center1;
64 center0.set(SkScalarAve(pts[0].fX, pts[1].fX),
65 SkScalarAve(pts[0].fY, pts[1].fY));
66 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5),
67 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4));
69 center1, (pts[1].fX - pts[0].fX) / 7,
70 center0, (pts[1].fX - pts[0].fX) / 2,
71 data.fColors, data.fPos, data.fCount, tm);
72}
#define SkScalarAve(a, b)
Definition SkScalar.h:74
#define SkIntToScalar(x)
Definition SkScalar.h:57
static SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t)
Definition SkScalar.h:131

◆ make3()

static void make3 ( ColorPos rec)
static

Definition at line 218 of file gradients_no_texture.cpp.

218 {
219 const SkColor colors[] = {
221 };
222 const SkScalar pos[] = {
223 0, 0, 0.5f, 0.5, 1, 1,
224 };
225 rec->construct(colors, pos, std::size(colors));
226}
constexpr SkColor SK_ColorBLUE
Definition SkColor.h:135
constexpr SkColor SK_ColorRED
Definition SkColor.h:126
constexpr SkColor SK_ColorGREEN
Definition SkColor.h:131

◆ MakeLinear()

static sk_sp< SkShader > MakeLinear ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm 
)
static

Definition at line 44 of file gradients_no_texture.cpp.

44 {
45 return SkGradientShader::MakeLinear(pts, data.fColors, data.fPos, data.fCount, tm);
46}
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)

◆ MakeRadial()

static sk_sp< SkShader > MakeRadial ( const SkPoint  pts[2],
const GradData data,
SkTileMode  tm 
)
static

Definition at line 48 of file gradients_no_texture.cpp.

48 {
50 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
51 SkScalarAve(pts[0].fY, pts[1].fY));
52 return SkGradientShader::MakeRadial(center, center.fX, data.fColors, data.fPos, data.fCount, tm);
53}
static SkScalar center(float pos0, float pos1)
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)

◆ MakeSweep()

static sk_sp< SkShader > MakeSweep ( const SkPoint  pts[2],
const GradData data,
SkTileMode   
)
static

Definition at line 55 of file gradients_no_texture.cpp.

55 {
57 center.set(SkScalarAve(pts[0].fX, pts[1].fX),
58 SkScalarAve(pts[0].fY, pts[1].fY));
59 return SkGradientShader::MakeSweep(center.fX, center.fY, data.fColors, data.fPos, data.fCount);
60}
static sk_sp< SkShader > MakeSweep(SkScalar cx, SkScalar cy, const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, SkScalar startAngle, SkScalar endAngle, uint32_t flags, const SkMatrix *localMatrix)

Variable Documentation

◆ gColors

constexpr SkColor gColors[]
constexpr

◆ gGradData

constexpr GradData gGradData[]
constexpr
Initial value:
= {
{ 1, gColors, nullptr },
{ 2, gColors, nullptr },
{ 3, gColors, nullptr },
{ 4, gColors, nullptr },
}
constexpr SkColor gColors[]

Definition at line 37 of file gradients_no_texture.cpp.

37 {
38 { 1, gColors, nullptr },
39 { 2, gColors, nullptr },
40 { 3, gColors, nullptr },
41 { 4, gColors, nullptr },
42};

◆ gGradMakers

constexpr GradMaker gGradMakers[]
constexpr
Initial value:
= {
}
static sk_sp< SkShader > MakeRadial()
static sk_sp< SkShader > MakeLinear()
static sk_sp< SkShader > Make2Conical(const SkPoint pts[2], const GradData &data, SkTileMode tm)
static sk_sp< SkShader > Make2Radial(const SkPoint pts[2], const GradData &data, SkTileMode tm)
static sk_sp< SkShader > MakeSweep(const SkPoint pts[2], const GradData &data, SkTileMode)

Definition at line 89 of file gradients_no_texture.cpp.