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 "gm.h" | 8 #include "gm.h" |
9 #include "SkAnimTimer.h" | 9 #include "SkAnimTimer.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 paint.setAntiAlias(true); | 29 paint.setAntiAlias(true); |
30 paint.setStyle(SkPaint::kStroke_Style); | 30 paint.setStyle(SkPaint::kStroke_Style); |
31 paint.setStrokeWidth(15); | 31 paint.setStrokeWidth(15); |
32 | 32 |
33 const SkScalar inset = paint.getStrokeWidth() + 4; | 33 const SkScalar inset = paint.getStrokeWidth() + 4; |
34 const SkScalar sweepAngle = 345; | 34 const SkScalar sweepAngle = 345; |
35 SkRandom rand; | 35 SkRandom rand; |
36 | 36 |
37 SkScalar sign = 1; | 37 SkScalar sign = 1; |
38 while (r.width() > paint.getStrokeWidth() * 3) { | 38 while (r.width() > paint.getStrokeWidth() * 3) { |
39 paint.setColor(rand.nextU() | (0xFF << 24)); | 39 paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 2
4))); |
40 SkScalar startAngle = rand.nextUScalar1() * 360; | 40 SkScalar startAngle = rand.nextUScalar1() * 360; |
41 | 41 |
42 SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f; | 42 SkScalar speed = SkScalarSqrt(16 / r.width()) * 0.5f; |
43 startAngle += fRotate * 360 * speed * sign; | 43 startAngle += fRotate * 360 * speed * sign; |
44 | 44 |
45 SkPath path; | 45 SkPath path; |
46 path.addArc(r, startAngle, sweepAngle); | 46 path.addArc(r, startAngle, sweepAngle); |
47 canvas->drawPath(path, paint); | 47 canvas->drawPath(path, paint); |
48 | 48 |
49 r.inset(inset, inset); | 49 r.inset(inset, inset); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 const SkScalar delta = paint.getStrokeWidth() * 3 / 2; | 138 const SkScalar delta = paint.getStrokeWidth() * 3 / 2; |
139 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24); | 139 SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24); |
140 SkRandom rand; | 140 SkRandom rand; |
141 | 141 |
142 SkScalar sign = 1; | 142 SkScalar sign = 1; |
143 while (r.width() > paint.getStrokeWidth() * 2) { | 143 while (r.width() > paint.getStrokeWidth() * 2) { |
144 SkAutoCanvasRestore acr(canvas, true); | 144 SkAutoCanvasRestore acr(canvas, true); |
145 canvas->rotate(fRotate * sign); | 145 canvas->rotate(fRotate * sign); |
146 | 146 |
147 paint.setColor(rand.nextU() | (0xFF << 24)); | 147 paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 2
4))); |
148 canvas->drawOval(r, paint); | 148 canvas->drawOval(r, paint); |
149 r.inset(delta, delta); | 149 r.inset(delta, delta); |
150 sign = -sign; | 150 sign = -sign; |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 bool onAnimate(const SkAnimTimer& timer) override { | 154 bool onAnimate(const SkAnimTimer& timer) override { |
155 fRotate = timer.scaled(60, 360); | 155 fRotate = timer.scaled(60, 360); |
156 return true; | 156 return true; |
157 } | 157 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 canvas->restore(); | 224 canvas->restore(); |
225 canvas->translate(0, 40); | 225 canvas->translate(0, 40); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 private: | 229 private: |
230 typedef skiagm::GM INHERITED; | 230 typedef skiagm::GM INHERITED; |
231 }; | 231 }; |
232 DEF_GM( return new ManyArcsGM; ) | 232 DEF_GM( return new ManyArcsGM; ) |
233 | 233 |
OLD | NEW |