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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::CreateTwoPointConical( | 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 = (pts[1].fX - pts[0].fX) / 10; |
63 SkScalar radius1 = SkScalarDiv(pts[1].fX - pts[0].fX, 3); | 63 SkScalar radius1 = (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); |
65 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); | 65 center1.set(pts[1].fX - radius1, pts[1].fY - radius1); |
66 return SkGradientShader::CreateTwoPointConical(center1, radius1, | 66 return SkGradientShader::CreateTwoPointConical(center1, radius1, |
67 center0, radius0, | 67 center0, radius0, |
68 data.fColors, data.fPos, | 68 data.fColors, data.fPos, |
69 data.fCount, tm); | 69 data.fCount, tm); |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha
der::TileMode tm); | 73 typedef SkShader* (*GradMaker)(const SkPoint pts[2], const GradData& data, SkSha
der::TileMode tm); |
(...skipping 169 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 |