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 | 7 |
8 #include "gm.h" | 8 #include "gm.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 SkScalar step = angle; | 40 SkScalar step = angle; |
41 | 41 |
42 SkPath path; | 42 SkPath path; |
43 path.moveTo(center); | 43 path.moveTo(center); |
44 | 44 |
45 while (length < (SkScalarHalf(size) - 10.f)) | 45 while (length < (SkScalarHalf(size) - 10.f)) |
46 { | 46 { |
47 SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX, | 47 SkPoint rp = SkPoint::Make(length*SkScalarCos(step) + center.fX, |
48 length*SkScalarSin(step) + center.fY); | 48 length*SkScalarSin(step) + center.fY); |
49 path.lineTo(rp); | 49 path.lineTo(rp); |
50 length += angle / SkScalarHalf(SK_ScalarPI); | 50 length += SkScalarDiv(angle, SkScalarHalf(SK_ScalarPI)); |
51 step += angle; | 51 step += angle; |
52 } | 52 } |
53 path.close(); | 53 path.close(); |
54 | 54 |
55 SkPaint paint; | 55 SkPaint paint; |
56 paint.setAntiAlias(true); | 56 paint.setAntiAlias(true); |
57 paint.setStyle(SkPaint::kStroke_Style); | 57 paint.setStyle(SkPaint::kStroke_Style); |
58 paint.setColor(0xFF007700); | 58 paint.setColor(0xFF007700); |
59 | 59 |
60 canvas->drawPath(path, paint); | 60 canvas->drawPath(path, paint); |
61 } | 61 } |
62 | 62 |
63 private: | 63 private: |
64 typedef GM INHERITED; | 64 typedef GM INHERITED; |
65 }; | 65 }; |
66 | 66 |
67 DEF_GM( return new StringArtGM; ) | 67 DEF_GM( return new StringArtGM; ) |
OLD | NEW |