2018-03-07 22:02:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2018 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkTrimPathEffect_DEFINED
|
|
|
|
#define SkTrimPathEffect_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkPathEffect.h"
|
2018-03-07 22:02:47 +00:00
|
|
|
|
|
|
|
class SK_API SkTrimPathEffect {
|
|
|
|
public:
|
2018-03-09 21:08:58 +00:00
|
|
|
enum class Mode {
|
|
|
|
kNormal, // return the subset path [start,stop]
|
|
|
|
kInverted, // return the complement/subset paths [0,start] + [stop,1]
|
|
|
|
};
|
|
|
|
|
2018-03-07 22:02:47 +00:00
|
|
|
/**
|
|
|
|
* Take start and stop "t" values (values between 0...1), and return a path that is that
|
|
|
|
* subset of the original path.
|
|
|
|
*
|
|
|
|
* e.g.
|
|
|
|
* Make(0.5, 1.0) --> return the 2nd half of the path
|
|
|
|
* Make(0.33333, 0.66667) --> return the middle third of the path
|
|
|
|
*
|
|
|
|
* The trim values apply to the entire path, so if it contains several contours, all of them
|
|
|
|
* are including in the calculation.
|
|
|
|
*
|
|
|
|
* startT and stopT must be 0..1 inclusive. If they are outside of that interval, they will
|
|
|
|
* be pinned to the nearest legal value. If either is NaN, null will be returned.
|
|
|
|
*
|
2018-03-09 21:08:58 +00:00
|
|
|
* Note: for Mode::kNormal, this will return one (logical) segment (even if it is spread
|
|
|
|
* across multiple contours). For Mode::kInverted, this will return 2 logical
|
2018-03-07 22:02:47 +00:00
|
|
|
* segments: 0...stopT and startT...1
|
|
|
|
*/
|
2018-03-09 21:08:58 +00:00
|
|
|
static sk_sp<SkPathEffect> Make(SkScalar startT, SkScalar stopT, Mode = Mode::kNormal);
|
2018-03-07 22:02:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|