Code example for PathDashPathEffect

0
        private static void makeEffects(PathEffect[] e, float phase) {
            e[0] = null;     // 沒有效果
            e[1] = new CornerPathEffect(10);
            e[2] = new DashPathEffect(new float[] {10, 5, 5, 5}, phase);
            e[3] = new PathDashPathEffect(makePathDash(), 12, phase,
                                          PathDashPathEffect.Style.ROTATE);
            e[4] = new ComposePathEffect(e[2], e[1]);
            e[5] = new ComposePathEffect(e[3], e[1]);
        } 
         
        @Override  
        protected void onDraw(Canvas canvas) {
            canvas.drawColor(Color.WHITE);
 
            RectF bounds = new RectF();
            path.computeBounds(bounds, false);
            canvas.translate(10 - bounds.left, 10 - bounds.top);
 
            makeEffects(pathEff, phase);
            phase += 1;
            invalidate();