You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.1 KiB
60 lines
1.1 KiB
package mightypork.utils.math.rect;
|
|
|
|
import mightypork.utils.annotations.FactoryMethod;
|
|
|
|
|
|
/**
|
|
* Immutable rect
|
|
*
|
|
* @author MightyPork
|
|
*/
|
|
public abstract class RectView extends RectMath<RectVal> {
|
|
|
|
/**
|
|
* Get a proxy at given rect
|
|
*
|
|
* @param observed observed rect
|
|
* @return view
|
|
*/
|
|
@FactoryMethod
|
|
public static RectView make(Rect observed)
|
|
{
|
|
return observed.view(); // let the rect handle it
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectVal move(double x, double y)
|
|
{
|
|
return RectVal.make(origin().add(x, y), size());
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectVal shrink(double left, double right, double top, double bottom)
|
|
{
|
|
return RectVal.make(origin().add(left, top), size().sub(left + right, top + bottom));
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectVal grow(double left, double right, double top, double bottom)
|
|
{
|
|
return RectVal.make(origin().sub(left, top), size().add(left + right, top + bottom));
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectVal round()
|
|
{
|
|
return RectVal.make(origin().round(), size().round());
|
|
}
|
|
|
|
@Override
|
|
public RectView view()
|
|
{
|
|
// must NOT call RectView.make, it'd cause infinite recursion.
|
|
return this; // wont change
|
|
}
|
|
|
|
}
|
|
|