Skia
2D Graphics Library
SkPathMeasure.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
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 
8 #ifndef SkPathMeasure_DEFINED
9 #define SkPathMeasure_DEFINED
10 
12 #include "include/core/SkPath.h"
13 #include "include/private/base/SkTDArray.h"
14 
15 class SK_API SkPathMeasure {
16 public:
24  SkPathMeasure(const SkPath& path, bool forceClosed, SkScalar resScale = 1);
26 
29 
33  void setPath(const SkPath*, bool forceClosed);
34 
39 
45  [[nodiscard]] bool getPosTan(SkScalar distance, SkPoint* position, SkVector* tangent);
46 
47  enum MatrixFlags {
48  kGetPosition_MatrixFlag = 0x01,
49  kGetTangent_MatrixFlag = 0x02,
50  kGetPosAndTan_MatrixFlag = kGetPosition_MatrixFlag | kGetTangent_MatrixFlag
51  };
52 
58  [[nodiscard]] bool getMatrix(SkScalar distance, SkMatrix* matrix,
59  MatrixFlags flags = kGetPosAndTan_MatrixFlag);
60 
67  bool getSegment(SkScalar startD, SkScalar stopD, SkPath* dst, bool startWithMoveTo);
68 
71  bool isClosed();
72 
76  bool nextContour();
77 
78 #ifdef SK_DEBUG
79  void dump();
80 #endif
81 
82 private:
84  sk_sp<SkContourMeasure> fContour;
85 };
86 
87 #endif
float SkScalar
Definition: SkScalar.h:14
Definition: SkContourMeasure.h:95
SkMatrix holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:53
Definition: SkPathMeasure.h:15
bool isClosed()
Return true if the current contour is closed()
bool getMatrix(SkScalar distance, SkMatrix *matrix, MatrixFlags flags=kGetPosAndTan_MatrixFlag)
Pins distance to 0 <= distance <= getLength(), and then computes the corresponding matrix (by calling...
SkScalar getLength()
Return the total length of the current contour, or 0 if no path is associated (e.g.
SkPathMeasure(SkPathMeasure &&)=default
bool nextContour()
Move to the next contour in the path.
MatrixFlags
Definition: SkPathMeasure.h:47
void setPath(const SkPath *, bool forceClosed)
Reset the pathmeasure with the specified path.
SkPathMeasure & operator=(SkPathMeasure &&)=default
SkPathMeasure(const SkPath &path, bool forceClosed, SkScalar resScale=1)
Initialize the pathmeasure with the specified path.
bool getSegment(SkScalar startD, SkScalar stopD, SkPath *dst, bool startWithMoveTo)
Given a start and stop distance, return in dst the intervening segment(s).
bool getPosTan(SkScalar distance, SkPoint *position, SkVector *tangent)
Pins distance to 0 <= distance <= getLength(), and then computes the corresponding position and tange...
SkPath contain geometry.
Definition: SkPath.h:58