Calculates the x-coordinate of the left edge given the other sides of the rectangle and an aspect ratio. - Android Graphics

Android examples for Graphics:Rectangle

Description

Calculates the x-coordinate of the left edge given the other sides of the rectangle and an aspect ratio.

Demo Code

//package com.java2s;

public class Main {
    /**/*from  w  ww. j a va 2  s .c  o  m*/
     * Calculates the x-coordinate of the left edge given the other sides of the
     * rectangle and an aspect ratio.
     */
    public static float calculateLeft(float top, float right, float bottom,
            float targetAspectRatio) {

        final float height = bottom - top;

        final float left = right - (targetAspectRatio * height);

        return left;
    }
}

Related Tutorials