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.
66 lines
1.0 KiB
66 lines
1.0 KiB
package mightypork.utils.math.rect;
|
|
|
|
|
|
import mightypork.utils.math.vect.Vect;
|
|
import mightypork.utils.math.vect.VectMutable;
|
|
import mightypork.utils.math.vect.VectVal;
|
|
|
|
|
|
class RectMutableImpl extends RectMutable {
|
|
|
|
final VectMutable pos = VectMutable.zero();
|
|
final VectMutable size = VectMutable.zero();
|
|
|
|
|
|
/**
|
|
* Create at given origin, with given size.
|
|
*
|
|
* @param x
|
|
* @param y
|
|
* @param width
|
|
* @param height
|
|
*/
|
|
public RectMutableImpl(double x, double y, double width, double height) {
|
|
this.pos.setTo(x, y);
|
|
this.size.setTo(width, height).abs();
|
|
}
|
|
|
|
|
|
@Override
|
|
public VectVal origin()
|
|
{
|
|
return pos.copy();
|
|
}
|
|
|
|
|
|
@Override
|
|
public VectVal size()
|
|
{
|
|
return size.copy();
|
|
}
|
|
|
|
|
|
@Override
|
|
protected RectMutable result(Vect newOrigin, Vect newSize)
|
|
{
|
|
setOrigin(newOrigin);
|
|
setSize(newSize);
|
|
return this;
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectMutable setOrigin(Vect origin)
|
|
{
|
|
this.pos.setTo(origin);
|
|
return this;
|
|
}
|
|
|
|
|
|
@Override
|
|
public RectMutable setSize(Vect size)
|
|
{
|
|
this.size.setTo(size).abs();
|
|
return this;
|
|
}
|
|
}
|
|
|