Home | History | Annotate | Download | only in effects
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef SkDiscretePathEffect_DEFINED
     18 #define SkDiscretePathEffect_DEFINED
     19 
     20 #include "SkPathEffect.h"
     21 
     22 /** \class SkDiscretePathEffect
     23 
     24     This path effect chops a path into discrete segments, and randomly displaces them.
     25 */
     26 class SkDiscretePathEffect : public SkPathEffect {
     27 public:
     28     /** Break the path into segments of segLength length, and randomly move the endpoints
     29         away from the original path by a maximum of deviation.
     30         Note: works on filled or framed paths
     31     */
     32     SkDiscretePathEffect(SkScalar segLength, SkScalar deviation);
     33 
     34     // overrides for SkPathEffect
     35     //  This method is not exported to java.
     36     virtual bool filterPath(SkPath* dst, const SkPath& src, SkScalar* width);
     37 
     38     // overrides for SkFlattenable
     39     //  This method is not exported to java.
     40     virtual Factory getFactory();
     41     //  This method is not exported to java.
     42     virtual void flatten(SkFlattenableWriteBuffer&);
     43 
     44 protected:
     45     SkDiscretePathEffect(SkFlattenableReadBuffer&);
     46 
     47 private:
     48     SkScalar fSegLength, fPerterb;
     49 
     50     static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
     51 
     52     typedef SkPathEffect INHERITED;
     53 };
     54 
     55 #endif
     56 
     57