SkDiscretePathEffect.h revision 9797272edfc73f18b4807751377518317991b880
1
2/*
3 * Copyright 2006 The Android Open Source Project
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9
10#ifndef SkDiscretePathEffect_DEFINED
11#define SkDiscretePathEffect_DEFINED
12
13#include "SkPathEffect.h"
14
15/** \class SkDiscretePathEffect
16
17    This path effect chops a path into discrete segments, and randomly displaces them.
18*/
19class SkDiscretePathEffect : public SkPathEffect {
20public:
21    /** Break the path into segments of segLength length, and randomly move the endpoints
22        away from the original path by a maximum of deviation.
23        Note: works on filled or framed paths
24    */
25    SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
26
27    virtual bool filterPath(SkPath* dst, const SkPath& src, SkStrokeRec*) SK_OVERRIDE;
28
29    SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
30
31protected:
32    SkDiscretePathEffect(SkFlattenableReadBuffer&);
33    virtual void flatten(SkFlattenableWriteBuffer&) const SK_OVERRIDE;
34
35private:
36    SkScalar fSegLength, fPerterb;
37
38    typedef SkPathEffect INHERITED;
39};
40
41#endif
42
43