Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Side by Side Diff: gm/beziers.cpp

Issue 2369933002: beziers: I missed an unsequenced moveTo() pair. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkPath.h" 9 #include "SkPath.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
11 11
12 #define W 400 12 #define W 400
13 #define H 400 13 #define H 400
14 #define N 10 14 #define N 10
15 15
16 constexpr SkScalar SH = SkIntToScalar(H); 16 constexpr SkScalar SH = SkIntToScalar(H);
17 17
18 static void rnd_quad(SkPath* p, SkPaint* paint, SkRandom& rand) { 18 static void rnd_quad(SkPath* p, SkPaint* paint, SkRandom& rand) {
19 p->moveTo(rand.nextRangeScalar(0, W), rand.nextRangeScalar(0, H)); 19 auto a = rand.nextRangeScalar(0,W),
20 b = rand.nextRangeScalar(0,H);
21 p->moveTo(a,b);
20 for (int x = 0; x < 2; ++x) { 22 for (int x = 0; x < 2; ++x) {
21 auto a = rand.nextRangeScalar(W/4, W), 23 auto c = rand.nextRangeScalar(W/4, W),
22 b = rand.nextRangeScalar( 0, H), 24 d = rand.nextRangeScalar( 0, H),
23 c = rand.nextRangeScalar( 0, W), 25 e = rand.nextRangeScalar( 0, W),
24 d = rand.nextRangeScalar(H/4, H); 26 f = rand.nextRangeScalar(H/4, H);
25 p->quadTo(a,b,c,d); 27 p->quadTo(c,d,e,f);
26 } 28 }
27 paint->setColor(rand.nextU()); 29 paint->setColor(rand.nextU());
28 SkScalar width = rand.nextRangeScalar(1, 5); 30 SkScalar width = rand.nextRangeScalar(1, 5);
29 width *= width; 31 width *= width;
30 paint->setStrokeWidth(width); 32 paint->setStrokeWidth(width);
31 paint->setAlpha(0xFF); 33 paint->setAlpha(0xFF);
32 } 34 }
33 35
34 static void rnd_cubic(SkPath* p, SkPaint* paint, SkRandom& rand) { 36 static void rnd_cubic(SkPath* p, SkPaint* paint, SkRandom& rand) {
35 auto a = rand.nextRangeScalar(0,W), 37 auto a = rand.nextRangeScalar(0,W),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 rnd_cubic(&p, &paint, rand); 85 rnd_cubic(&p, &paint, rand);
84 canvas->drawPath(p, paint); 86 canvas->drawPath(p, paint);
85 } 87 }
86 } 88 }
87 89
88 private: 90 private:
89 typedef skiagm::GM INHERITED; 91 typedef skiagm::GM INHERITED;
90 }; 92 };
91 93
92 DEF_GM( return new BeziersGM; ) 94 DEF_GM( return new BeziersGM; )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698