| 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 "SkBlurMask.h" |
| 10 #include "SkBlurMaskFilter.h" | 10 #include "SkBlurMaskFilter.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 path.offset(0, -100); | 258 path.offset(0, -100); |
| 259 | 259 |
| 260 SkPaint paint; | 260 SkPaint paint; |
| 261 paint.setAntiAlias(true); | 261 paint.setAntiAlias(true); |
| 262 paint.setTextSize(40); | 262 paint.setTextSize(40); |
| 263 | 263 |
| 264 paint.setStyle(SkPaint::kStroke_Style); | 264 paint.setStyle(SkPaint::kStroke_Style); |
| 265 canvas->drawPath(path, paint); | 265 canvas->drawPath(path, paint); |
| 266 paint.setStyle(SkPaint::kFill_Style); | 266 paint.setStyle(SkPaint::kFill_Style); |
| 267 | 267 |
| 268 SkCanvas::TextOnPathMethod method = SkCanvas::kStretch_TextOnPathMethod; |
| 269 SkMatrix matrix; |
| 270 |
| 268 SkScalar x = 50; | 271 SkScalar x = 50; |
| 269 paint.setColor(0xFF008800); | 272 paint.setColor(0xFF008800); |
| 270 canvas->drawTextOnPathHV(text, len, path, | 273 matrix.setTranslate(x, paint.getTextSize()*2/3); |
| 271 x, paint.getTextSize()*2/3, paint); | 274 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 272 paint.setColor(SK_ColorRED); | 275 paint.setColor(SK_ColorRED); |
| 273 canvas->drawTextOnPathHV(text, len, path, | 276 matrix.setTranslate(x + 60, 0); |
| 274 x + 60, 0, paint); | 277 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 275 paint.setColor(SK_ColorBLUE); | 278 paint.setColor(SK_ColorBLUE); |
| 276 canvas->drawTextOnPathHV(text, len, path, | 279 matrix.setTranslate(x + 120, -paint.getTextSize()*2/3); |
| 277 x + 120, -paint.getTextSize()*2/3, paint); | 280 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 278 | 281 |
| 279 path.offset(0, 200); | 282 path.offset(0, 200); |
| 280 paint.setTextAlign(SkPaint::kRight_Align); | 283 paint.setTextAlign(SkPaint::kRight_Align); |
| 281 | 284 |
| 282 text = "Matrices"; | 285 text = "Matrices"; |
| 283 len = strlen(text); | 286 len = strlen(text); |
| 284 SkScalar pathLen = getpathlen(path); | 287 SkScalar pathLen = getpathlen(path); |
| 285 SkMatrix matrix; | |
| 286 | 288 |
| 287 paint.setColor(SK_ColorBLACK); | 289 paint.setColor(SK_ColorBLACK); |
| 288 paint.setStyle(SkPaint::kStroke_Style); | 290 paint.setStyle(SkPaint::kStroke_Style); |
| 289 canvas->drawPath(path, paint); | 291 canvas->drawPath(path, paint); |
| 290 paint.setStyle(SkPaint::kFill_Style); | 292 paint.setStyle(SkPaint::kFill_Style); |
| 291 | 293 |
| 292 paint.setTextSize(50); | 294 paint.setTextSize(50); |
| 293 canvas->drawTextOnPath(text, len, path, NULL, paint); | 295 canvas->drawTextOnPath(text, len, path, NULL, method, paint); |
| 294 | 296 |
| 295 paint.setColor(SK_ColorRED); | 297 paint.setColor(SK_ColorRED); |
| 296 matrix.setScale(-SK_Scalar1, SK_Scalar1); | 298 matrix.setScale(-SK_Scalar1, SK_Scalar1); |
| 297 matrix.postTranslate(pathLen, 0); | 299 matrix.postTranslate(pathLen, 0); |
| 298 canvas->drawTextOnPath(text, len, path, &matrix, paint); | 300 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 299 | 301 |
| 300 paint.setColor(SK_ColorBLUE); | 302 paint.setColor(SK_ColorBLUE); |
| 301 matrix.setScale(SK_Scalar1, -SK_Scalar1); | 303 matrix.setScale(SK_Scalar1, -SK_Scalar1); |
| 302 canvas->drawTextOnPath(text, len, path, &matrix, paint); | 304 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 303 | 305 |
| 304 paint.setColor(0xFF008800); | 306 paint.setColor(0xFF008800); |
| 305 matrix.setScale(-SK_Scalar1, -SK_Scalar1); | 307 matrix.setScale(-SK_Scalar1, -SK_Scalar1); |
| 306 matrix.postTranslate(pathLen, 0); | 308 matrix.postTranslate(pathLen, 0); |
| 307 canvas->drawTextOnPath(text, len, path, &matrix, paint); | 309 canvas->drawTextOnPath(text, len, path, &matrix, method, paint); |
| 308 } | 310 } |
| 309 | 311 |
| 310 /////////////////////////////////////////////////////////////////////////////// | 312 /////////////////////////////////////////////////////////////////////////////// |
| 311 | 313 |
| 312 #include "SkImageDecoder.h" | 314 #include "SkImageDecoder.h" |
| 313 #include "SkOSFile.h" | 315 #include "SkOSFile.h" |
| 314 #include "SkRandom.h" | 316 #include "SkRandom.h" |
| 315 #include "SkStream.h" | 317 #include "SkStream.h" |
| 316 | 318 |
| 317 static SkShader* make_shader0(SkIPoint* size) { | 319 static SkShader* make_shader0(SkIPoint* size) { |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 } | 720 } |
| 719 | 721 |
| 720 private: | 722 private: |
| 721 typedef SampleView INHERITED; | 723 typedef SampleView INHERITED; |
| 722 }; | 724 }; |
| 723 | 725 |
| 724 ////////////////////////////////////////////////////////////////////////////// | 726 ////////////////////////////////////////////////////////////////////////////// |
| 725 | 727 |
| 726 static SkView* MyFactory() { return new SlideView; } | 728 static SkView* MyFactory() { return new SlideView; } |
| 727 static SkViewRegister reg(MyFactory); | 729 static SkViewRegister reg(MyFactory); |
| OLD | NEW |