OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 #include "SampleCode.h" | 7 #include "SampleCode.h" |
8 #include "SkView.h" | 8 #include "SkView.h" |
9 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkGradientShader.h" | 10 #include "SkGradientShader.h" |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkRegion.h" | 12 #include "SkRegion.h" |
13 #include "SkShader.h" | 13 #include "SkShader.h" |
14 #include "SkUtils.h" | 14 #include "SkUtils.h" |
15 #include "Sk1DPathEffect.h" | 15 #include "Sk1DPathEffect.h" |
16 #include "SkCornerPathEffect.h" | 16 #include "SkCornerPathEffect.h" |
17 #include "SkPathMeasure.h" | 17 #include "SkPathMeasure.h" |
18 #include "SkRandom.h" | 18 #include "SkRandom.h" |
19 #include "SkColorPriv.h" | 19 #include "SkColorPriv.h" |
20 #include "SkColorFilter.h" | 20 #include "SkColorFilter.h" |
21 #include "SkDither.h" | 21 #include "SkDither.h" |
| 22 #include "sk_tool_utils.h" |
22 | 23 |
23 static void draw_sweep(SkCanvas* c, int width, int height, SkScalar angle) { | 24 static void draw_sweep(SkCanvas* c, int width, int height, SkScalar angle) { |
24 SkRect r; | 25 SkRect r; |
25 SkPaint p; | 26 SkPaint p; |
26 | 27 |
27 p.setAntiAlias(true); | 28 p.setAntiAlias(true); |
28 // p.setDither(true); | 29 // p.setDither(true); |
29 p.setStrokeWidth(SkIntToScalar(width/10)); | 30 p.setStrokeWidth(SkIntToScalar(width/10)); |
30 p.setStyle(SkPaint::kStroke_Style); | 31 p.setStyle(SkPaint::kStroke_Style); |
31 | 32 |
32 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); | 33 r.set(0, 0, SkIntToScalar(width), SkIntToScalar(height)); |
33 | 34 |
34 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; | 35 // SkColor colors[] = { SK_ColorRED, SK_ColorBLUE, SK_ColorGREEN, SK_Colo
rCYAN }; |
35 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; | 36 SkColor colors[] = { 0x4c737373, 0x4c737373, 0xffffd300 }; |
36 p.setShader(SkGradientShader::MakeSweep(r.centerX(), r.centerY(), | 37 p.setShader(SkGradientShader::MakeSweep(r.centerX(), r.centerY(), |
37 colors, nullptr, SK_ARRAY_COUNT(colo
rs))); | 38 colors, nullptr, SK_ARRAY_COUNT(colo
rs))); |
38 | 39 |
39 SkAutoCanvasRestore acr(c, true); | 40 SkAutoCanvasRestore acr(c, true); |
40 | 41 sk_tool_utils::rotate_about(c, angle, r.centerX(), r.centerY()); |
41 c->translate(r.centerX(), r.centerY()); | |
42 c->rotate(angle); | |
43 c->translate(-r.centerX(), -r.centerY()); | |
44 | 42 |
45 SkRect bounds = r; | 43 SkRect bounds = r; |
46 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); | 44 r.inset(p.getStrokeWidth(), p.getStrokeWidth()); |
47 SkRect innerBounds = r; | 45 SkRect innerBounds = r; |
48 | 46 |
49 if (true) { | 47 if (true) { |
50 c->drawOval(r, p); | 48 c->drawOval(r, p); |
51 } else { | 49 } else { |
52 SkScalar x = r.centerX(); | 50 SkScalar x = r.centerX(); |
53 SkScalar y = r.centerY(); | 51 SkScalar y = r.centerY(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 } | 165 } |
168 | 166 |
169 private: | 167 private: |
170 typedef SampleView INHERITED; | 168 typedef SampleView INHERITED; |
171 }; | 169 }; |
172 | 170 |
173 ////////////////////////////////////////////////////////////////////////////// | 171 ////////////////////////////////////////////////////////////////////////////// |
174 | 172 |
175 static SkView* MyFactory() { return new DitherView; } | 173 static SkView* MyFactory() { return new DitherView; } |
176 static SkViewRegister reg(MyFactory); | 174 static SkViewRegister reg(MyFactory); |
OLD | NEW |