union two JavaFX Rectangle - Java JavaFX

Java examples for JavaFX:Rectangle

Description

union two JavaFX Rectangle

Demo Code


//package com.java2s;

import javafx.geometry.Point2D;

import javafx.scene.shape.Rectangle;

public class Main {
    static public Rectangle union(Point2D a, Point2D b) {
        double x = Math.min(a.getX(), b.getX());
        double y = Math.min(a.getY(), b.getY());
        double width = Math.abs(a.getX() - b.getX());
        double height = Math.abs(a.getY() - b.getY());
        return new Rectangle(x, y, width, height);
    }/*w w w.j a  v a2 s .  com*/
}

Related Tutorials