Changeset 778


Ignore:
Timestamp:
05/11/18 23:38:10 (2 years ago)
Author:
Maciej Komosinski
Message:

A few useful functions added for 2D operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/2d.h

    r766 r778  
    6262        T horizontal() const {return left+right;}
    6363        T vertical() const {return top+bottom;}
     64        bool operator==(const XYMargin &other) const {return left==other.left && top==other.top && right==other.right && bottom==other.bottom;}
     65        XYMargin normalized() const {return XYMargin(max(left,T(0)),max(top,T(0)),max(right,T(0)),max(bottom,T(0)));}
    6466};
    6567
     
    128130XYMargin<T> marginTowards(const XYRect &r) const
    129131{
    130 return XYMargin<T>(r.p.x, r.p.y,
     132return XYMargin<T>(r.p.x-p.x, r.p.y-p.y,
    131133                (p.x+size.x)-(r.p.x+r.size.x), (p.y+size.y)-(r.p.y+r.size.y));
    132134}
Note: See TracChangeset for help on using the changeset viewer.