Changeset 1327 for cpp/common/2d.h


Ignore:
Timestamp:
12/26/24 01:37:08 (6 days ago)
Author:
Maciej Komosinski
Message:

Added a helper function and an operator

File:
1 edited

Legend:

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

    r1284 r1327  
    11// This file is a part of Framsticks SDK.  http://www.framsticks.com/
    2 // Copyright (C) 1999-2023  Maciej Komosinski and Szymon Ulatowski.
     2// Copyright (C) 1999-2024  Maciej Komosinski and Szymon Ulatowski.
    33// See LICENSE.txt for details.
    44
     
    4646        static XY average(const XY &v1, const XY &v2) { return XY((v1.x + v2.x) * 0.5, (v1.y + v2.y) * 0.5); }
    4747        double getDirection() const { return atan2(y, x); }
     48        float aspect() const { return float(x) / float(y); }
    4849        static XY interpolate(const XY &v1, const XY &v2, double t) { return universal_lerp(v1, v2, t); }
    4950        XY toInt() const { return XY(int(x), int(y)); }
     
    6869        void operator=(T x) { left = top = right = bottom = x; }
    6970        XYMargin operator-() const { return XYMargin(-left, -top, -right, -bottom); }
     71        XYMargin operator+(const XYMargin<T> &m) const { return XYMargin(left + m.left, top + m.top, right + m.right, bottom + m.bottom); }
    7072        void operator=(const XYMargin<T> &other) { left = other.left; top = other.top; right = other.right; bottom = other.bottom; }
    7173        T horizontal() const { return left + right; }
     
    184186                return r;
    185187        }
    186        
     188
    187189        XYRect intersection(const XYRect &r) const
    188190        {
Note: See TracChangeset for help on using the changeset viewer.