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 "SampleCode.h" | 8 #include "SampleCode.h" |
| 9 #include "SkBlurMask.h" |
9 #include "SkBlurDrawLooper.h" | 10 #include "SkBlurDrawLooper.h" |
10 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
11 #include "SkPath.h" | 12 #include "SkPath.h" |
12 #include "SkPathMeasure.h" | 13 #include "SkPathMeasure.h" |
13 | 14 |
14 #define REPEAT_COUNT 1 | 15 #define REPEAT_COUNT 1 |
15 | 16 |
16 static void textStrokePath(SkCanvas* canvas) { | 17 static void textStrokePath(SkCanvas* canvas) { |
17 SkPaint paint; | 18 SkPaint paint; |
18 SkPath path; | 19 SkPath path; |
19 SkRect rect; | 20 SkRect rect; |
20 | 21 |
21 canvas->save(); | 22 canvas->save(); |
22 canvas->scale(SkIntToScalar(250),SkIntToScalar(250)); | 23 canvas->scale(SkIntToScalar(250),SkIntToScalar(250)); |
23 | 24 |
24 rect.set(SkFloatToScalar(0.0f), SkFloatToScalar(0.21f), | 25 rect.set(SkFloatToScalar(0.0f), SkFloatToScalar(0.21f), |
25 SkFloatToScalar(0.78f), SkFloatToScalar(0.99f)); | 26 SkFloatToScalar(0.78f), SkFloatToScalar(0.99f)); |
26 | 27 |
27 path.addArc(rect, SkIntToScalar(280), SkIntToScalar(350)); | 28 path.addArc(rect, SkIntToScalar(280), SkIntToScalar(350)); |
28 | 29 |
29 paint.setAntiAlias(true); | 30 paint.setAntiAlias(true); |
30 paint.setStyle(SkPaint::kStroke_Style); | 31 paint.setStyle(SkPaint::kStroke_Style); |
31 paint.setColor(0xFFFF0000); | 32 paint.setColor(0xFFFF0000); |
32 paint.setTextSize(SkFloatToScalar(0.085f)); | 33 paint.setTextSize(SkFloatToScalar(0.085f)); |
33 paint.setStrokeWidth(SkFloatToScalar(.005f)); | 34 paint.setStrokeWidth(SkFloatToScalar(.005f)); |
34 | 35 |
35 canvas->drawPath(path, paint); | 36 canvas->drawPath(path, paint); |
36 | 37 |
37 paint.setLooper(new SkBlurDrawLooper(SkFloatToScalar(0.002f), | 38 paint.setLooper(new SkBlurDrawLooper(SK_ColorBLACK, |
38 SkFloatToScalar(0.0f), | 39 SkBlurMask::ConvertRadiusToSigma(SkFloa
tToScalar(0.002f)), |
39 SkFloatToScalar(0.0f), | 40 SkFloatToScalar(0.0f), |
40 (SkColor)0xFF000000))->unref(); | 41 SkFloatToScalar(0.0f)))->unref(); |
41 | 42 |
42 const char* text = "DRAWING STROKED TEXT WITH A BLUR ON A PATH"; | 43 const char* text = "DRAWING STROKED TEXT WITH A BLUR ON A PATH"; |
43 size_t len = strlen(text); | 44 size_t len = strlen(text); |
44 | 45 |
45 canvas->drawTextOnPathHV(text, len, path, 0, | 46 canvas->drawTextOnPathHV(text, len, path, 0, |
46 SkFloatToScalar(-0.025f), paint); | 47 SkFloatToScalar(-0.025f), paint); |
47 canvas->restore(); | 48 canvas->restore(); |
48 } | 49 } |
49 | 50 |
50 static void textPathMatrix(SkCanvas* canvas) { | 51 static void textPathMatrix(SkCanvas* canvas) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 typedef SampleView INHERITED; | 166 typedef SampleView INHERITED; |
166 }; | 167 }; |
167 | 168 |
168 ////////////////////////////////////////////////////////////////////////////// | 169 ////////////////////////////////////////////////////////////////////////////// |
169 | 170 |
170 static SkView* MyFactory() { | 171 static SkView* MyFactory() { |
171 return new TextOnPathView; | 172 return new TextOnPathView; |
172 } | 173 } |
173 | 174 |
174 static SkViewRegister reg(MyFactory); | 175 static SkViewRegister reg(MyFactory); |
OLD | NEW |