Blame |
Last modification |
View Log
| RSS feed
package com.gebauz.bauzoid.math;
public class Rect
{
public float left = 0;
public float top = 0;
public float right = 0;
public float bottom = 0;
public Rect(float _left, float _top, float _right, float _bottom)
{
left = _left; top = _top; right = _right; bottom = _bottom;
}
public Rect(Rect other)
{
this.left = other.left; this.top = other.top; this.right = other.right; this.bottom = other.bottom;
}
public Rect(Vector4 other)
{
this.left = other.x; this.top = other.y; this.right = other.z; this.bottom = other.w;
}
public boolean isInside(float x, float y)
{
if ((x < left) || (x > right) ||
(y < top) || (y > bottom))
return false;
return true;
}
public boolean isOverlapping(Rect other)
{
if (((other.left < this.left) || (other.left > this.right)) &&
((other.right < this.left) || (other.right > this.right)))
return false;
if (((other.top < this.top) || (other.top > this.bottom)) &&
((other.bottom < this.top) || (other.bottom > this.bottom)))
return false;
return true;
}
public void setXYWH(float x, float y, float w, float h)
{
left = x;
top = y;
right = x + w;
bottom = y + h;
}
public float getWidth()
{
return (right-left);
}
public float getHeight()
{
return (bottom-top);
}
}