1 // Copyright 2019 Google LLC. 2 // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3 #include "tools/fiddle/examples.h" 4 REG_FIDDLE(Path_addRect, 256, 128, false, 0) { draw(SkCanvas * canvas)5 void draw(SkCanvas* canvas) { 6 SkPaint paint; 7 paint.setStrokeWidth(15); 8 paint.setStrokeCap(SkPaint::kSquare_Cap); 9 float intervals[] = { 5, 21.75f }; 10 paint.setStyle(SkPaint::kStroke_Style); 11 paint.setPathEffect(SkDashPathEffect::Make(intervals, std::size(intervals), 0)); 12 SkPath path; 13 path.addRect({20, 20, 100, 100}, SkPathDirection::kCW); 14 canvas->drawPath(path, paint); 15 path.rewind(); 16 path.addRect({140, 20, 220, 100}, SkPathDirection::kCCW); 17 canvas->drawPath(path, paint); 18 } 19 } // END FIDDLE 20