bug530095.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "gm/gm.h"
  8. #include "include/core/SkCanvas.h"
  9. #include "include/core/SkColor.h"
  10. #include "include/core/SkPaint.h"
  11. #include "include/core/SkPath.h"
  12. #include "include/core/SkPathEffect.h"
  13. #include "include/core/SkScalar.h"
  14. #include "include/core/SkTypes.h"
  15. #include "include/effects/SkDashPathEffect.h"
  16. DEF_SIMPLE_GM(bug530095, canvas, 900, 1200) {
  17. SkPath path1, path2;
  18. path1.addCircle(200, 200, 124);
  19. path2.addCircle(2, 2, 1.24f);
  20. SkPaint paint;
  21. paint.setAntiAlias(true);
  22. paint.setStyle(SkPaint::kStroke_Style);
  23. paint.setStrokeWidth(26);
  24. SkScalar intervals[] = {700, 700 };
  25. int intervalCount = (int) SK_ARRAY_COUNT(intervals);
  26. paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, -40));
  27. canvas->drawPath(path1, paint);
  28. paint.setStrokeWidth(0.26f);
  29. SkScalar smIntervals[] = {7, 7 };
  30. int smIntervalCount = (int) SK_ARRAY_COUNT(smIntervals);
  31. paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, -0.40f));
  32. canvas->save();
  33. canvas->scale(100, 100);
  34. canvas->translate(4, 0);
  35. canvas->drawPath(path2, paint);
  36. canvas->restore();
  37. paint.setStrokeWidth(26);
  38. paint.setPathEffect(SkDashPathEffect::Make(intervals, intervalCount, 0));
  39. canvas->save();
  40. canvas->translate(0, 400);
  41. canvas->drawPath(path1, paint);
  42. canvas->restore();
  43. paint.setStrokeWidth(0.26f);
  44. paint.setPathEffect(SkDashPathEffect::Make(smIntervals, smIntervalCount, 0));
  45. canvas->scale(100, 100);
  46. canvas->translate(4, 4);
  47. canvas->drawPath(path2, paint);
  48. }
  49. DEF_SIMPLE_GM(bug591993, canvas, 40, 140) {
  50. SkPaint p;
  51. p.setColor(SK_ColorRED);
  52. p.setAntiAlias(true);
  53. p.setStyle(SkPaint::kStroke_Style);
  54. p.setStrokeCap(SkPaint::kRound_Cap);
  55. p.setStrokeWidth(10);
  56. const SkScalar intervals[] = { 100, 100 };
  57. p.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 100));
  58. canvas->drawLine(20, 20, 120, 20, p);
  59. }