OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "gm.h" | 8 #include "gm.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 | 10 |
11 #define W 400 | 11 #define W 400 |
12 #define H 400 | 12 #define H 400 |
13 #define N 10 | 13 #define N 10 |
14 | 14 |
15 static const SkScalar SW = SkIntToScalar(W); | |
16 static const SkScalar SH = SkIntToScalar(H); | 15 static const SkScalar SH = SkIntToScalar(H); |
17 | 16 |
18 static void rnd_quad(SkPath* p, SkPaint* paint, SkLCGRandom& rand) { | 17 static void rnd_quad(SkPath* p, SkPaint* paint, SkLCGRandom& rand) { |
19 p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H)); | 18 p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H)); |
20 for (int x = 0; x < 2; ++x) { | 19 for (int x = 0; x < 2; ++x) { |
21 p->quadTo(rand.nextRangeScalar(W / 4, W), rand.nextRangeScalar(0, H), | 20 p->quadTo(rand.nextRangeScalar(W / 4, W), rand.nextRangeScalar(0, H), |
22 rand.nextRangeScalar(0, W), rand.nextRangeScalar(H / 4, H)); | 21 rand.nextRangeScalar(0, W), rand.nextRangeScalar(H / 4, H)); |
23 } | 22 } |
24 paint->setColor(rand.nextU()); | 23 paint->setColor(rand.nextU()); |
25 SkScalar width = rand.nextRangeScalar(1, 5); | 24 SkScalar width = rand.nextRangeScalar(1, 5); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 canvas->drawPath(p, paint); | 77 canvas->drawPath(p, paint); |
79 } | 78 } |
80 } | 79 } |
81 | 80 |
82 private: | 81 private: |
83 typedef skiagm::GM INHERITED; | 82 typedef skiagm::GM INHERITED; |
84 }; | 83 }; |
85 | 84 |
86 static skiagm::GM* F0(void*) { return new BeziersGM; } | 85 static skiagm::GM* F0(void*) { return new BeziersGM; } |
87 static skiagm::GMRegistry R0(F0); | 86 static skiagm::GMRegistry R0(F0); |
OLD | NEW |