This library encapsulates the PathExtended
object which serves as a extension to the parent Path class of Flutter. Internally a sampled representation of the Path is stored and updated, allowing to manipulate the Path object in powerful ways.
🚧 This library is still at early-stage development and might be subject to breaking API changes!!! 🚧
Here is increasingly growing list with all available parameters and their visual effects. The animation serves for illustration purposes only. For creating such animations I would like to refer to drawing_animation, another package of mine.
Effect | Example |
---|---|
ContinousLine (default) |
|
DiscretePathEffect |
|
DashPathEffect |
|
PathDashPathEffect |
Path p = Path()..addRect(Rect.fromCircle(center: Offset.zero, radius: 2.0));
PathExtended pp = PathExtended(p)
..applyPathEffect(DashPathEffect([10,2], dashOffset: -1))
..addPath(circle(0,30.0),Offset.zero);
The API design for the PathEffect classes is inspired by PathEffect for native Android but with some differences:
- A
PathEffect
is applied to each Path object and not to the Paint object - Additionally a
PathModifier
is introduced. Contrary to thePathEffect
the overall contour of the Path is changed. Internally aPathModifier
manipulates the sampled representation directly while aPathEffect
only changes the way how the sampling points are connected. This allows to combine aPathModifier
with aPathEffect
: For instance, a straight line can be transformed into a dashed sinus-curve. Soon aPathExtendedBuilder
will be exposed which allows to set up a PathExtended object without rebuilding the internal structure every time. - Any feedback on the overall API design is really appreciated!
Internal sampling rate for the path data is currently hardcoded. This might noticeable when sampling a big amount of path data (bad performance) and also for very small paths (edgy lines).
PathEffect
: How to determine optimal_delta
value for sampling. Also consider defining_delta
over amount of resulting sampling points (required for path morping). Your Path is discrete now: What happens when the Path is scaled, consider resampling dynamically.PathDashPathEffect
: Rotate Path elements according to normal of current Offset (see PathDashPathEffect.Style)PathDashPathEffect
: Implementadvance
field of PathDashPathEffect by setting inital offset to-dashOffset
DashPathEffect
: Double dash pattern when odd (for now blocked by assert)
- PathEffect: DashPathEffect
- PathEffect: DiscretePathEffect
- PathEffect: PathDashPathEffect
- PathModifier: sin-wave
- PathModifier: zick-zack
- PathModifier: smoothing/simplify
- (static) Lerp between two Paths/ Morphing
-
PathExtendedBuilder
for better performance