Get point between p1 and p2 by percent. - Android Graphics

Android examples for Graphics:Path Point

Description

Get point between p1 and p2 by percent.

Demo Code


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

public class Main {

    public static PointF getPointByPercent(PointF p1, PointF p2,
            float percent) {
        return new PointF(evaluateValue(percent, p1.x, p2.x),
                evaluateValue(percent, p1.y, p2.y));
    }// w  w  w .  j  a va 2  s .  c om

    public static float evaluateValue(float fraction, Number start,
            Number end) {
        return start.floatValue() + (end.floatValue() - start.floatValue())
                * fraction;
    }
}

Related Tutorials