Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: samplecode/SampleTextOnPath.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samplecode/SampleText.cpp ('k') | samplecode/TransitionView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkBlurMask.h"
10 #include "SkBlurDrawLooper.h" 10 #include "SkBlurDrawLooper.h"
11 #include "SkCanvas.h" 11 #include "SkCanvas.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkPathMeasure.h" 13 #include "SkPathMeasure.h"
14 14
15 #define REPEAT_COUNT 1 15 #define REPEAT_COUNT 1
16 16
17 static void textStrokePath(SkCanvas* canvas) { 17 static void textStrokePath(SkCanvas* canvas) {
18 SkPaint paint; 18 SkPaint paint;
19 SkPath path; 19 SkPath path;
20 SkRect rect; 20 SkRect rect;
21 21
22 canvas->save(); 22 canvas->save();
23 canvas->scale(SkIntToScalar(250),SkIntToScalar(250)); 23 canvas->scale(SkIntToScalar(250),SkIntToScalar(250));
24 24
25 rect.set(SkFloatToScalar(0.0f), SkFloatToScalar(0.21f), 25 rect.set(0.0f, 0.21f,
26 SkFloatToScalar(0.78f), SkFloatToScalar(0.99f)); 26 0.78f, 0.99f);
27 27
28 path.addArc(rect, SkIntToScalar(280), SkIntToScalar(350)); 28 path.addArc(rect, SkIntToScalar(280), SkIntToScalar(350));
29 29
30 paint.setAntiAlias(true); 30 paint.setAntiAlias(true);
31 paint.setStyle(SkPaint::kStroke_Style); 31 paint.setStyle(SkPaint::kStroke_Style);
32 paint.setColor(0xFFFF0000); 32 paint.setColor(0xFFFF0000);
33 paint.setTextSize(SkFloatToScalar(0.085f)); 33 paint.setTextSize(0.085f);
34 paint.setStrokeWidth(SkFloatToScalar(.005f)); 34 paint.setStrokeWidth(.005f);
35 35
36 canvas->drawPath(path, paint); 36 canvas->drawPath(path, paint);
37 37
38 paint.setLooper(new SkBlurDrawLooper(SK_ColorBLACK, 38 paint.setLooper(new SkBlurDrawLooper(SK_ColorBLACK,
39 SkBlurMask::ConvertRadiusToSigma(SkFloa tToScalar(0.002f)), 39 SkBlurMask::ConvertRadiusToSigma(0.002f ),
40 SkFloatToScalar(0.0f), 40 0.0f,
41 SkFloatToScalar(0.0f)))->unref(); 41 0.0f))->unref();
42 42
43 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";
44 size_t len = strlen(text); 44 size_t len = strlen(text);
45 45
46 canvas->drawTextOnPathHV(text, len, path, 0, 46 canvas->drawTextOnPathHV(text, len, path, 0,
47 SkFloatToScalar(-0.025f), paint); 47 -0.025f, paint);
48 canvas->restore(); 48 canvas->restore();
49 } 49 }
50 50
51 static void textPathMatrix(SkCanvas* canvas) { 51 static void textPathMatrix(SkCanvas* canvas) {
52 SkPaint paint; 52 SkPaint paint;
53 SkPath path; 53 SkPath path;
54 SkMatrix matrix; 54 SkMatrix matrix;
55 55
56 path.moveTo(SkIntToScalar(050), SkIntToScalar(200)); 56 path.moveTo(SkIntToScalar(050), SkIntToScalar(200));
57 path.quadTo(SkIntToScalar(250), SkIntToScalar(000), 57 path.quadTo(SkIntToScalar(250), SkIntToScalar(000),
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 typedef SampleView INHERITED; 166 typedef SampleView INHERITED;
167 }; 167 };
168 168
169 ////////////////////////////////////////////////////////////////////////////// 169 //////////////////////////////////////////////////////////////////////////////
170 170
171 static SkView* MyFactory() { 171 static SkView* MyFactory() {
172 return new TextOnPathView; 172 return new TextOnPathView;
173 } 173 }
174 174
175 static SkViewRegister reg(MyFactory); 175 static SkViewRegister reg(MyFactory);
OLDNEW
« no previous file with comments | « samplecode/SampleText.cpp ('k') | samplecode/TransitionView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698