get Point By Percent - Android Graphics

Android examples for Graphics:Path Point

Description

get Point By Percent

Demo Code

/**// w  ww.ja v a  2s .  com
 * Copyright 2015 bingoogolapple
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//package com.java2s;

import android.graphics.PointF;

public class Main {
    public static PointF getPointByPercent(PointF p1, PointF p2,
            float percent) {
        return new PointF(evaluate(percent, p1.x, p2.x), evaluate(percent,
                p1.y, p2.y));
    }

    public static Float evaluate(float fraction, Number startValue,
            Number endValue) {
        float startFloat = startValue.floatValue();
        return startFloat + fraction * (endValue.floatValue() - startFloat);
    }
}

Related Tutorials