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

Android examples for Graphics:Rectangle

Description

Calculates the y-coordinate of the top edge given the other sides of the rectangle and an aspect ratio.

Demo Code

//package com.java2s;

public class Main {
    /**//w  w  w  .  j av  a2s.c o m
     * Calculates the y-coordinate of the top edge given the other sides of the
     * rectangle and an aspect ratio.
     */
    public static float calculateTop(float left, float right, float bottom,
            float targetAspectRatio) {

        final float width = right - left;

        final float top = bottom - (width / targetAspectRatio);

        return top;
    }
}

Related Tutorials