intersect two JavaFX Rectangle - Java JavaFX

Java examples for JavaFX:Rectangle

Description

intersect two JavaFX Rectangle

Demo Code


//package com.java2s;

import javafx.scene.shape.Rectangle;

public class Main {
    static public Rectangle intersect(Rectangle a, Rectangle b) {
        double x = Math.max(a.getX(), b.getX());
        double y = Math.max(a.getY(), b.getY());
        double width = Math.min(a.getWidth(), b.getWidth());
        double height = Math.min(a.getHeight(), b.getHeight());
        return new Rectangle(x, y, width, height);
    }/*from   ww  w .j a  v  a2 s . c  o m*/
}

Related Tutorials