Calculates the height of a rectangle given the left and right edges and an aspect ratio. - Android Graphics

Android examples for Graphics:Rectangle

Description

Calculates the height of a rectangle given the left and right edges and an aspect ratio.

Demo Code

//package com.java2s;

public class Main {
    /**/*from w ww  .  j  a v  a 2s  . c om*/
     * Calculates the height of a rectangle given the left and right edges and
     * an aspect ratio.
     */
    public static float calculateHeight(float left, float right,
            float targetAspectRatio) {

        final float width = right - left;
        final float height = width / targetAspectRatio;

        return height;
    }
}

Related Tutorials