Calculates the x-coordinate of the right 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 right edge given the other sides of the rectangle and an aspect ratio.

Demo Code

//package com.java2s;

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

        final float height = bottom - top;

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

        return right;
    }
}

Related Tutorials