Changeset 905


Ignore:
Timestamp:
01/07/20 17:56:21 (4 years ago)
Author:
Maciej Komosinski
Message:

Added XYRect::fitAspect(float aspect)

File:
1 edited

Legend:

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

    r898 r905  
    161161        }
    162162
     163        XYRect fitAspect(float aspect) ///< place a new rectangle having 'aspect' inside the rectangle
     164        {
     165                XYRect r;
     166                r.size=size;
     167                if (size.x < size.y*aspect)
     168                        r.size.y = r.size.x/aspect;
     169                else
     170                        r.size.x = r.size.y*aspect;
     171                r.p=p+(size-r.size)*0.5;
     172                return r;               
     173        }
     174       
    163175        XYRect intersection(const XYRect& r) const
    164176        {
Note: See TracChangeset for help on using the changeset viewer.