Rogue: Savage Rats, a retro-themed dungeon crawler
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.
 
 
rogue-savage-rats/src/mightypork/utils/math/rect/FixedRect.java

105 lines
1.6 KiB

package mightypork.utils.math.rect;
import mightypork.utils.math.coord.FixedCoord;
import mightypork.utils.math.coord.Vec;
import mightypork.utils.math.coord.VecView;
public class FixedRect extends RectView {
private final VecView pos;
private final VecView size;
/**
* Create at 0,0 with zero size
*/
public FixedRect() {
pos = Vec.ZERO;
size = Vec.ZERO;
}
/**
* Create at 0,0 with given size
*
* @param width
* @param height
*/
public FixedRect(double width, double height) {
this(0, 0, width, height);
}
/**
* Create at given origin, with given size.
*
* @param origin
* @param width
* @param height
*/
public FixedRect(Vec origin, double width, double height) {
this(origin.x(), origin.y(), width, height);
}
/**
* Create at 0,0 with given size.
*
* @param size
*/
public FixedRect(Vec size) {
this(0, 0, size.x(), size.y());
}
/**
* Create at given origin, with given size.
*
* @param origin
* @param size
*/
public FixedRect(Vec origin, Vec size) {
this(origin.x(), origin.y(), size.x(), size.y());
}
/**
* Create at given origin, with given size.
*
* @param x
* @param y
* @param width
* @param height
*/
public FixedRect(double x, double y, double width, double height) {
pos = new FixedCoord(x, y);
size = new FixedCoord(Math.abs(width), Math.abs(height));
}
/**
* Create as copy of another
*
* @param other copied
*/
public FixedRect(Rect other) {
this(other.getOrigin(), other.getSize());
}
@Override
public VecView getOrigin()
{
return pos;
}
@Override
public VecView getSize()
{
return size;
}
}