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 "SkView.h" | 9 #include "SkView.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 drawpatches(canvas, paint, 10, 10, &patch); | 288 drawpatches(canvas, paint, 10, 10, &patch); |
289 | 289 |
290 paint.setShader(NULL); | 290 paint.setShader(NULL); |
291 paint.setAntiAlias(true); | 291 paint.setAntiAlias(true); |
292 paint.setStrokeWidth(SkIntToScalar(5)); | 292 paint.setStrokeWidth(SkIntToScalar(5)); |
293 canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fP
ts, paint); | 293 canvas->drawPoints(SkCanvas::kPoints_PointMode, SK_ARRAY_COUNT(fPts), fP
ts, paint); |
294 | 294 |
295 canvas->translate(0, SkIntToScalar(300)); | 295 canvas->translate(0, SkIntToScalar(300)); |
296 | 296 |
297 paint.setAntiAlias(false); | 297 paint.setAntiAlias(false); |
298 paint.setShader(fShader1); | 298 |
| 299 { |
| 300 static int gAngle; |
| 301 SkMatrix m; |
| 302 m.setRotate(SkIntToScalar(gAngle++)); |
| 303 SkShader* s = SkShader::CreateLocalMatrixShader(fShader1, m); |
| 304 paint.setShader(s)->unref(); |
| 305 } |
299 patch.setBounds(fSize1.fX, fSize1.fY); | 306 patch.setBounds(fSize1.fX, fSize1.fY); |
300 drawpatches(canvas, paint, 10, 10, &patch); | 307 drawpatches(canvas, paint, 10, 10, &patch); |
| 308 |
| 309 this->inval(NULL); |
301 } | 310 } |
302 | 311 |
303 class PtClick : public Click { | 312 class PtClick : public Click { |
304 public: | 313 public: |
305 int fIndex; | 314 int fIndex; |
306 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} | 315 PtClick(SkView* view, int index) : Click(view), fIndex(index) {} |
307 }; | 316 }; |
308 | 317 |
309 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { | 318 static bool hittest(const SkPoint& pt, SkScalar x, SkScalar y) { |
310 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); | 319 return SkPoint::Length(pt.fX - x, pt.fY - y) < SkIntToScalar(5); |
(...skipping 16 matching lines...) Expand all Loading... |
327 } | 336 } |
328 | 337 |
329 private: | 338 private: |
330 typedef SampleView INHERITED; | 339 typedef SampleView INHERITED; |
331 }; | 340 }; |
332 | 341 |
333 ////////////////////////////////////////////////////////////////////////////// | 342 ////////////////////////////////////////////////////////////////////////////// |
334 | 343 |
335 static SkView* MyFactory() { return new PatchView; } | 344 static SkView* MyFactory() { return new PatchView; } |
336 static SkViewRegister reg(MyFactory); | 345 static SkViewRegister reg(MyFactory); |
OLD | NEW |