SkTrimPathEffect.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2018 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. #ifndef SkTrimPathEffect_DEFINED
  8. #define SkTrimPathEffect_DEFINED
  9. #include "SkPathEffect.h"
  10. class SK_API SkTrimPathEffect {
  11. public:
  12. enum class Mode {
  13. kNormal, // return the subset path [start,stop]
  14. kInverted, // return the complement/subset paths [0,start] + [stop,1]
  15. };
  16. /**
  17. * Take start and stop "t" values (values between 0...1), and return a path that is that
  18. * subset of the original path.
  19. *
  20. * e.g.
  21. * Make(0.5, 1.0) --> return the 2nd half of the path
  22. * Make(0.33333, 0.66667) --> return the middle third of the path
  23. *
  24. * The trim values apply to the entire path, so if it contains several contours, all of them
  25. * are including in the calculation.
  26. *
  27. * startT and stopT must be 0..1 inclusive. If they are outside of that interval, they will
  28. * be pinned to the nearest legal value. If either is NaN, null will be returned.
  29. *
  30. * Note: for Mode::kNormal, this will return one (logical) segment (even if it is spread
  31. * across multiple contours). For Mode::kInverted, this will return 2 logical
  32. * segments: 0...stopT and startT...1
  33. */
  34. static sk_sp<SkPathEffect> Make(SkScalar startT, SkScalar stopT, Mode = Mode::kNormal);
  35. };
  36. #endif