OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkTArray.h" | 10 #include "SkTArray.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // small circle. This is listed last so that it has device coords far | 254 // small circle. This is listed last so that it has device coords far |
255 // from the origin (small area relative to x,y values). | 255 // from the origin (small area relative to x,y values). |
256 fPaths.push_back().addCircle(0, 0, SkFloatToScalar(1.2f)); | 256 fPaths.push_back().addCircle(0, 0, SkFloatToScalar(1.2f)); |
257 } | 257 } |
258 | 258 |
259 virtual void onDraw(SkCanvas* canvas) { | 259 virtual void onDraw(SkCanvas* canvas) { |
260 this->makePaths(); | 260 this->makePaths(); |
261 | 261 |
262 SkPaint paint; | 262 SkPaint paint; |
263 paint.setAntiAlias(true); | 263 paint.setAntiAlias(true); |
264 SkRandom rand; | 264 SkLCGRandom rand; |
265 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); | 265 canvas->translate(20 * SK_Scalar1, 20 * SK_Scalar1); |
266 | 266 |
267 // As we've added more paths this has gotten pretty big. Scale the whole thi
ng down. | 267 // As we've added more paths this has gotten pretty big. Scale the whole thi
ng down. |
268 canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3); | 268 canvas->scale(2 * SK_Scalar1 / 3, 2 * SK_Scalar1 / 3); |
269 | 269 |
270 for (int i = 0; i < fPaths.count(); ++i) { | 270 for (int i = 0; i < fPaths.count(); ++i) { |
271 canvas->save(); | 271 canvas->save(); |
272 // position the path, and make it at off-integer coords. | 272 // position the path, and make it at off-integer coords. |
273 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10, | 273 canvas->translate(SK_Scalar1 * 200 * (i % 5) + SK_Scalar1 / 10, |
274 SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10); | 274 SK_Scalar1 * 200 * (i / 5) + 9 * SK_Scalar1 / 10); |
(...skipping 13 matching lines...) Expand all Loading... |
288 typedef GM INHERITED; | 288 typedef GM INHERITED; |
289 SkTArray<SkPath> fPaths; | 289 SkTArray<SkPath> fPaths; |
290 }; | 290 }; |
291 | 291 |
292 ////////////////////////////////////////////////////////////////////////////// | 292 ////////////////////////////////////////////////////////////////////////////// |
293 | 293 |
294 static GM* MyFactory(void*) { return new ConvexPathsGM; } | 294 static GM* MyFactory(void*) { return new ConvexPathsGM; } |
295 static GMRegistry reg(MyFactory); | 295 static GMRegistry reg(MyFactory); |
296 | 296 |
297 } | 297 } |
OLD | NEW |