Calculates the width of a rectangle given the top and bottom edges and an aspect ratio. - Android Graphics

Android examples for Graphics:Rectangle

Description

Calculates the width of a rectangle given the top and bottom edges and an aspect ratio.

Demo Code

//package com.java2s;

public class Main {
    /**//from w  w  w .j a  v  a  2  s.co  m
     * Calculates the width of a rectangle given the top and bottom edges and an
     * aspect ratio.
     */
    public static float calculateWidth(float top, float bottom,
            float targetAspectRatio) {

        final float height = bottom - top;
        final float width = targetAspectRatio * height;

        return width;
    }
}

Related Tutorials