OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 #include "gm.h" | 7 #include "gm.h" |
8 #include "SkGradientShader.h" | 8 #include "SkGradientShader.h" |
9 | 9 |
10 using namespace skiagm; | 10 using namespace skiagm; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 SkScalarAve(pts[0].fY, pts[1].fY)); | 44 SkScalarAve(pts[0].fY, pts[1].fY)); |
45 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat
a.fPos, data.fCount); | 45 return SkGradientShader::CreateSweep(center.fX, center.fY, data.fColors, dat
a.fPos, data.fCount); |
46 } | 46 } |
47 | 47 |
48 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShade
r::TileMode tm) { | 48 static SkShader* Make2Radial(const SkPoint pts[2], const GradData& data, SkShade
r::TileMode tm) { |
49 SkPoint center0, center1; | 49 SkPoint center0, center1; |
50 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), | 50 center0.set(SkScalarAve(pts[0].fX, pts[1].fX), |
51 SkScalarAve(pts[0].fY, pts[1].fY)); | 51 SkScalarAve(pts[0].fY, pts[1].fY)); |
52 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), | 52 center1.set(SkScalarInterp(pts[0].fX, pts[1].fX, SkIntToScalar(3)/5), |
53 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); | 53 SkScalarInterp(pts[0].fY, pts[1].fY, SkIntToScalar(1)/4)); |
54 return SkGradientShader::CreateTwoPointRadial( | 54 return SkGradientShader::CreateTwoPointConical( |
55 center1, (pts[1].fX - pts[0].fX) / 7, | 55 center1, (pts[1].fX - pts[0].fX) / 7, |
56 center0, (pts[1].fX - pts[0].fX) / 2, | 56 center0, (pts[1].fX - pts[0].fX) / 2, |
57 data.fColors, data.fPos, data.fCount, tm); | 57 data.fColors, data.fPos, data.fCount, tm); |
58 } | 58 } |
59 | 59 |
60 static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShad
er::TileMode tm) { | 60 static SkShader* Make2Conical(const SkPoint pts[2], const GradData& data, SkShad
er::TileMode tm) { |
61 SkPoint center0, center1; | 61 SkPoint center0, center1; |
62 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); | 62 SkScalar radius0 = SkScalarDiv(pts[1].fX - pts[0].fX, 10); |
63 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); | 63 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); |
64 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); | 64 center0.set(pts[0].fX + radius0, pts[0].fY + radius0); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } | 243 } |
244 | 244 |
245 private: | 245 private: |
246 typedef GM INHERITED; | 246 typedef GM INHERITED; |
247 }; | 247 }; |
248 | 248 |
249 /////////////////////////////////////////////////////////////////////////////// | 249 /////////////////////////////////////////////////////////////////////////////// |
250 | 250 |
251 DEF_GM( return SkNEW(GradientsNoTextureGM)); | 251 DEF_GM( return SkNEW(GradientsNoTextureGM)); |
252 DEF_GM( return SkNEW(GradientsManyColorsGM)); | 252 DEF_GM( return SkNEW(GradientsManyColorsGM)); |
OLD | NEW |