blob: 8d882fdfaa88f93a38a0de48cd491009540c9121 [file] [log] [blame]
caryclark1a7eb262016-01-21 07:07:02 -08001/*
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
Mike Kleinc0bd9f92019-04-23 12:05:21 -05008#include "gm/gm.h"
Ben Wagner6a34f3a2019-05-01 10:59:30 -04009#include "include/core/SkCanvas.h"
10#include "include/core/SkColor.h"
11#include "include/core/SkPaint.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050012#include "include/core/SkPath.h"
Ben Wagner6a34f3a2019-05-01 10:59:30 -040013#include "include/core/SkPathEffect.h"
14#include "include/core/SkScalar.h"
15#include "include/core/SkTypes.h"
Mike Kleinc0bd9f92019-04-23 12:05:21 -050016#include "include/effects/SkDashPathEffect.h"
caryclark1a7eb262016-01-21 07:07:02 -080017
18DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
19 SkPath path1, path2;
20 path1.addCircle(200, 200, 124);
21 path2.addCircle(2, 2, 1.24f);
22
23 SkPaint paint;
24 paint.setAntiAlias(true);
25 paint.setStyle(SkPaint::kStroke_Style);
26 paint.setStrokeWidth(26);
27 SkScalar intervals[] = {700, 700 };
28 int intervalCount = (int) SK_ARRAY_COUNT(intervals);
reeda4393342016-03-18 11:22:57 -070029 paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40));
caryclark1a7eb262016-01-21 07:07:02 -080030 canvas->drawPath(path1, paint);
31
32 paint.setStrokeWidth(0.26f);
33 SkScalar smIntervals[] = {7, 7 };
34 int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals);
reeda4393342016-03-18 11:22:57 -070035 paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f));
caryclark1a7eb262016-01-21 07:07:02 -080036 canvas->save();
37 canvas->scale(100, 100);
38 canvas->translate(4, 0);
39 canvas->drawPath(path2, paint);
40 canvas->restore();
41
42 paint.setStrokeWidth(26);
reeda4393342016-03-18 11:22:57 -070043 paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
caryclark1a7eb262016-01-21 07:07:02 -080044 canvas->save();
45 canvas->translate(0, 400);
46 canvas->drawPath(path1, paint);
47 canvas->restore();
48
49 paint.setStrokeWidth(0.26f);
reeda4393342016-03-18 11:22:57 -070050 paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0));
caryclark1a7eb262016-01-21 07:07:02 -080051 canvas->scale(100, 100);
52 canvas->translate(4, 4);
53 canvas->drawPath(path2, paint);
54}
caryclarkd3cfd942016-03-17 05:33:28 -070055
56DEF_SIMPLE_GM(bug591993, canvas, 40, 140) {
57 SkPaint p;
58 p.setColor(SK_ColorRED);
59 p.setAntiAlias(true);
60 p.setStyle(SkPaint::kStroke_Style);
61 p.setStrokeCap(SkPaint::kRound_Cap);
62 p.setStrokeWidth(10);
reeda4393342016-03-18 11:22:57 -070063 const SkScalar intervals[] = { 100, 100 };
64 p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100));
caryclarkd3cfd942016-03-17 05:33:28 -070065 canvas->drawLine(20, 20, 120, 20, p);
66}