caryclark | 1a7eb26 | 2016-01-21 07:07:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
| 9 | #include "SkPath.h" |
| 10 | #include "SkDashPathEffect.h" |
| 11 | |
| 12 | DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) { |
| 13 | SkPath path1, path2; |
| 14 | path1.addCircle(200, 200, 124); |
| 15 | path2.addCircle(2, 2, 1.24f); |
| 16 | |
| 17 | SkPaint paint; |
| 18 | paint.setAntiAlias(true); |
| 19 | paint.setStyle(SkPaint::kStroke_Style); |
| 20 | paint.setStrokeWidth(26); |
| 21 | SkScalar intervals[] = {700, 700 }; |
| 22 | int intervalCount = (int) SK_ARRAY_COUNT(intervals); |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 23 | paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40)); |
caryclark | 1a7eb26 | 2016-01-21 07:07:02 -0800 | [diff] [blame] | 24 | canvas->drawPath(path1, paint); |
| 25 | |
| 26 | paint.setStrokeWidth(0.26f); |
| 27 | SkScalar smIntervals[] = {7, 7 }; |
| 28 | int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals); |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 29 | paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f)); |
caryclark | 1a7eb26 | 2016-01-21 07:07:02 -0800 | [diff] [blame] | 30 | canvas->save(); |
| 31 | canvas->scale(100, 100); |
| 32 | canvas->translate(4, 0); |
| 33 | canvas->drawPath(path2, paint); |
| 34 | canvas->restore(); |
| 35 | |
| 36 | paint.setStrokeWidth(26); |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 37 | paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0)); |
caryclark | 1a7eb26 | 2016-01-21 07:07:02 -0800 | [diff] [blame] | 38 | canvas->save(); |
| 39 | canvas->translate(0, 400); |
| 40 | canvas->drawPath(path1, paint); |
| 41 | canvas->restore(); |
| 42 | |
| 43 | paint.setStrokeWidth(0.26f); |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 44 | paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0)); |
caryclark | 1a7eb26 | 2016-01-21 07:07:02 -0800 | [diff] [blame] | 45 | canvas->scale(100, 100); |
| 46 | canvas->translate(4, 4); |
| 47 | canvas->drawPath(path2, paint); |
| 48 | } |
caryclark | d3cfd94 | 2016-03-17 05:33:28 -0700 | [diff] [blame] | 49 | |
| 50 | DEF_SIMPLE_GM(bug591993, canvas, 40, 140) { |
| 51 | SkPaint p; |
| 52 | p.setColor(SK_ColorRED); |
| 53 | p.setAntiAlias(true); |
| 54 | p.setStyle(SkPaint::kStroke_Style); |
| 55 | p.setStrokeCap(SkPaint::kRound_Cap); |
| 56 | p.setStrokeWidth(10); |
reed | a439334 | 2016-03-18 11:22:57 -0700 | [diff] [blame] | 57 | const SkScalar intervals[] = { 100, 100 }; |
| 58 | p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100)); |
caryclark | d3cfd94 | 2016-03-17 05:33:28 -0700 | [diff] [blame] | 59 | canvas->drawLine(20, 20, 120, 20, p); |
| 60 | } |