OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 | 7 |
8 #include "SampleCode.h" | 8 #include "SampleCode.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 SkScalar fYFreq; | 68 SkScalar fYFreq; |
69 SkScalar fSeed; | 69 SkScalar fSeed; |
70 SkPoint fPts[SkPatchUtils::kNumCtrlPts]; | 70 SkPoint fPts[SkPatchUtils::kNumCtrlPts]; |
71 SkScalar fTexX; | 71 SkScalar fTexX; |
72 SkScalar fTexY; | 72 SkScalar fTexY; |
73 SkScalar fTexScale; | 73 SkScalar fTexScale; |
74 SkMatrix fInvMatrix; | 74 SkMatrix fInvMatrix; |
75 public: | 75 public: |
76 PerlinPatchView() : fXFreq(0.025f), fYFreq(0.025f), fSeed(0.0f), | 76 PerlinPatchView() : fXFreq(0.025f), fYFreq(0.025f), fSeed(0.0f), |
77 fTexX(100.0), fTexY(50.0), fTexScale(1.0f) { | 77 fTexX(100.0), fTexY(50.0), fTexScale(1.0f) { |
| 78 const SkScalar s = 2; |
78 // The order of the colors and points is clockwise starting at upper-lef
t corner. | 79 // The order of the colors and points is clockwise starting at upper-lef
t corner. |
79 //top points | 80 //top points |
80 fPts[0].set(100, 100); | 81 fPts[0].set(100 * s, 100 * s); |
81 fPts[1].set(150, 50); | 82 fPts[1].set(150 * s, 50 * s); |
82 fPts[2].set(250, 150); | 83 fPts[2].set(250 * s, 150 * s); |
83 fPts[3].set(300, 100); | 84 fPts[3].set(300 * s, 100 * s); |
84 //right points | 85 //right points |
85 fPts[4].set(275, 150); | 86 fPts[4].set(275 * s, 150 * s); |
86 fPts[5].set(350, 250); | 87 fPts[5].set(350 * s, 250 * s); |
87 //bottom points | 88 //bottom points |
88 fPts[6].set(300, 300); | 89 fPts[6].set(300 * s, 300 * s); |
89 fPts[7].set(250, 250); | 90 fPts[7].set(250 * s, 250 * s); |
90 //left points | 91 //left points |
91 fPts[8].set(150, 350); | 92 fPts[8].set(150 * s, 350 * s); |
92 fPts[9].set(100, 300); | 93 fPts[9].set(100 * s, 300 * s); |
93 fPts[10].set(50, 250); | 94 fPts[10].set(50 * s, 250 * s); |
94 fPts[11].set(150, 150); | 95 fPts[11].set(150 * s, 150 * s); |
95 | 96 |
96 const SkColor colors[SkPatchUtils::kNumCorners] = { | 97 const SkColor colors[SkPatchUtils::kNumCorners] = { |
97 0xFF5555FF, 0xFF8888FF, 0xFFCCCCFF | 98 0xFF5555FF, 0xFF8888FF, 0xFFCCCCFF |
98 }; | 99 }; |
99 const SkPoint points[2] = { SkPoint::Make(0.0f, 0.0f), | 100 const SkPoint points[2] = { SkPoint::Make(0.0f, 0.0f), |
100 SkPoint::Make(100.0f, 100.0f) }; | 101 SkPoint::Make(100.0f, 100.0f) }; |
101 fShader0 = SkGradientShader::CreateLinear(points, | 102 fShader0 = SkGradientShader::CreateLinear(points, |
102 colors, | 103 colors, |
103 NULL, | 104 NULL, |
104 3, | 105 3, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 this->inval(nullptr); | 204 this->inval(nullptr); |
204 return true; | 205 return true; |
205 } | 206 } |
206 | 207 |
207 private: | 208 private: |
208 typedef SampleView INHERITED; | 209 typedef SampleView INHERITED; |
209 }; | 210 }; |
210 | 211 |
211 DEF_SAMPLE( return new PerlinPatchView(); ) | 212 DEF_SAMPLE( return new PerlinPatchView(); ) |
212 | 213 |
OLD | NEW |