Calculate Bezier Point For Cubic - Android Graphics

Android examples for Graphics:Path Point

Description

Calculate Bezier Point For Cubic

Demo Code


//package com.java2s;
import android.graphics.PointF;

public class Main {

    public static PointF CalculateBezierPointForCubic(float t, PointF p0,
            PointF p1, PointF p2, PointF p3) {
        PointF point = new PointF();
        float temp = 1 - t;
        point.x = p0.x * temp * temp * temp + 3 * p1.x * t * temp * temp
                + 3 * p2.x * t * t * temp + p3.x * t * t * t;
        point.y = p0.y * temp * temp * temp + 3 * p1.y * t * temp * temp
                + 3 * p2.y * t * t * temp + p3.y * t * t * t;
        return point;
    }/*from   w  ww .jav a 2  s.c om*/
}

Related Tutorials