Path_FillType_b.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #if 0 // Disabled until updated to use current API.
  2. // Copyright 2019 Google LLC.
  3. // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
  4. #include "tools/fiddle/examples.h"
  5. // HASH=d2c33dc791cd165dcc2423226ba5b095
  6. REG_FIDDLE(Path_FillType_b, 256, 230, false, 0) {
  7. void draw(SkCanvas* canvas) {
  8. SkPath path;
  9. path.addRect({20, 10, 80, 70}, SkPath::kCW_Direction);
  10. path.addRect({40, 30, 100, 90}, SkPath::kCW_Direction);
  11. SkPaint strokePaint;
  12. strokePaint.setStyle(SkPaint::kStroke_Style);
  13. SkRect clipRect = {0, 0, 128, 128};
  14. canvas->drawPath(path, strokePaint);
  15. canvas->drawLine({0, 50}, {120, 50}, strokePaint);
  16. SkPaint textPaint;
  17. textPaint.setAntiAlias(true);
  18. SkScalar textHPos[] = { 10, 30, 60, 90, 110 };
  19. canvas->drawPosTextH("01210", 5, textHPos, 48, textPaint);
  20. textPaint.setTextSize(18);
  21. canvas->translate(0, 128);
  22. canvas->scale(.5f, .5f);
  23. canvas->drawString("inverse", 384, 150, textPaint);
  24. SkPaint fillPaint;
  25. for (auto fillType : { SkPath::kWinding_FillType, SkPath::kEvenOdd_FillType,
  26. SkPath::kInverseWinding_FillType, SkPath::kInverseEvenOdd_FillType } ) {
  27. canvas->save();
  28. canvas->clipRect(clipRect);
  29. path.setFillType(fillType);
  30. canvas->drawPath(path, fillPaint);
  31. canvas->restore();
  32. canvas->drawString(fillType & 1 ? "even-odd" : "winding", 64, 170, textPaint);
  33. canvas->translate(128, 0);
  34. }
  35. }
  36. } // END FIDDLE
  37. #endif // Disabled until updated to use current API.