Beispiel #1
0
void FloatRect::fitToPoints(const FloatPoint& p0, const FloatPoint& p1) {
  float left = std::min(p0.x(), p1.x());
  float top = std::min(p0.y(), p1.y());
  float right = std::max(p0.x(), p1.x());
  float bottom = std::max(p0.y(), p1.y());

  setLocationAndSizeFromEdges(left, top, right, bottom);
}
Beispiel #2
0
void FloatRect::extend(const FloatPoint& p) {
  float minX = std::min(x(), p.x());
  float minY = std::min(y(), p.y());
  float maxX = std::max(this->maxX(), p.x());
  float maxY = std::max(this->maxY(), p.y());

  setLocationAndSizeFromEdges(minX, minY, maxX, maxY);
}
Beispiel #3
0
void FloatRect::uniteEvenIfEmpty(const FloatRect& other) {
  float minX = std::min(x(), other.x());
  float minY = std::min(y(), other.y());
  float maxX = std::max(this->maxX(), other.maxX());
  float maxY = std::max(this->maxY(), other.maxY());

  setLocationAndSizeFromEdges(minX, minY, maxX, maxY);
}
void FloatRect::fitToPoints(const FloatPoint& p0, const FloatPoint& p1, const FloatPoint& p2, const FloatPoint& p3)
{
    float left = min4(p0.x(), p1.x(), p2.x(), p3.x());
    float top = min4(p0.y(), p1.y(), p2.y(), p3.y());
    float right = max4(p0.x(), p1.x(), p2.x(), p3.x());
    float bottom = max4(p0.y(), p1.y(), p2.y(), p3.y());

    setLocationAndSizeFromEdges(left, top, right, bottom);
}
Beispiel #5
0
void FloatRect::intersect(const FloatRect& other) {
  float left = std::max(x(), other.x());
  float top = std::max(y(), other.y());
  float right = std::min(maxX(), other.maxX());
  float bottom = std::min(maxY(), other.maxY());

  // Return a clean empty rectangle for non-intersecting cases.
  if (left >= right || top >= bottom) {
    left = 0;
    top = 0;
    right = 0;
    bottom = 0;
  }

  setLocationAndSizeFromEdges(left, top, right, bottom);
}
void FloatRect::intersect(const FloatRect& other)
{
    float l = max(x(), other.x());
    float t = max(y(), other.y());
    float r = min(maxX(), other.maxX());
    float b = min(maxY(), other.maxY());

    // Return a clean empty rectangle for non-intersecting cases.
    if (l >= r || t >= b) {
        l = 0;
        t = 0;
        r = 0;
        b = 0;
    }

    setLocationAndSizeFromEdges(l, t, r, b);
}
Beispiel #7
0
void FloatRect::unite(const FloatRect& other)
{
    // Handle empty special cases first.
    if (other.isEmpty())
        return;
    if (isEmpty()) {
        *this = other;
        return;
    }

    float l = min(x(), other.x());
    float t = min(y(), other.y());
    float r = max(maxX(), other.maxX());
    float b = max(maxY(), other.maxY());

    setLocationAndSizeFromEdges(l, t, r, b);
}
Beispiel #8
0
void FloatRect::uniteIfNonZero(const FloatRect& other)
{
    // Handle empty special cases first.
    if (!other.width() && !other.height())
        return;
    if (!width() && !height()) {
        *this = other;
        return;
    }

    float left = min(x(), other.x());
    float top = min(y(), other.y());
    float right = max(maxX(), other.maxX());
    float bottom = max(maxY(), other.maxY());

    setLocationAndSizeFromEdges(left, top, right, bottom);
}