mirror of
https://github.com/XITRIX/NXKit.git
synced 2026-05-30 11:46:52 +00:00
114 lines
3.1 KiB
C++
114 lines
3.1 KiB
C++
#pragma once
|
|
|
|
#include "src/gpu/ganesh/gl/builders/GrGLProgramBuilder.h"
|
|
|
|
namespace NXKit {
|
|
|
|
typedef float NXFloat;
|
|
|
|
struct NXAffineTransform;
|
|
struct NXTransform3D;
|
|
|
|
struct NXPoint {
|
|
NXFloat x, y;
|
|
|
|
NXPoint();
|
|
NXPoint(NXFloat x, NXFloat y);
|
|
|
|
bool operator==(const NXPoint& rhs) const;
|
|
bool operator!=(const NXPoint& rhs) const;
|
|
NXPoint operator+(const NXPoint& first) const;
|
|
NXPoint operator-(const NXPoint& first) const;
|
|
NXPoint& operator+=(const NXPoint& rhs);
|
|
NXPoint& operator-=(const NXPoint& rhs);
|
|
NXPoint operator/(const NXFloat& rhs) const;
|
|
NXPoint operator*(const NXFloat& rhs) const;
|
|
|
|
[[nodiscard]] NXPoint applying(const NXAffineTransform& t) const;
|
|
[[nodiscard]] NXFloat distanceToSegment(NXPoint v, NXPoint w) const;
|
|
|
|
[[nodiscard]] bool valid() const;
|
|
[[nodiscard]] NXFloat magnitude() const;
|
|
|
|
static NXPoint zero;
|
|
};
|
|
|
|
struct NXSize {
|
|
NXFloat width, height;
|
|
|
|
NXSize();
|
|
NXSize(NXFloat width, NXFloat height);
|
|
|
|
bool operator==(const NXSize &rhs) const;
|
|
bool operator!=(const NXSize &rhs) const;
|
|
|
|
NXSize operator+(const NXSize &first) const;
|
|
NXSize operator-(const NXSize &first) const;
|
|
NXSize &operator+=(const NXSize &rhs);
|
|
NXSize &operator-=(const NXSize &rhs);
|
|
|
|
NXSize operator*(const NXFloat &first) const;
|
|
NXSize operator/(const NXFloat &first) const;
|
|
NXSize &operator*=(const NXFloat &rhs);
|
|
NXSize &operator/=(const NXFloat &rhs);
|
|
|
|
[[nodiscard]] bool valid() const;
|
|
// NXSize inset(UIEdgeInsets inset) const;
|
|
};
|
|
|
|
struct NXRect {
|
|
NXPoint origin;
|
|
NXSize size;
|
|
|
|
NXRect();
|
|
NXRect(NXPoint origin, NXSize size);
|
|
NXRect(NXFloat x, NXFloat y, NXFloat width, NXFloat height);
|
|
|
|
[[nodiscard]] NXFloat width() const;
|
|
[[nodiscard]] NXFloat height() const;
|
|
|
|
[[nodiscard]] NXFloat minX() const;
|
|
[[nodiscard]] NXFloat midX() const;
|
|
[[nodiscard]] NXFloat maxX() const;
|
|
|
|
[[nodiscard]] NXFloat minY() const;
|
|
[[nodiscard]] NXFloat midY() const;
|
|
[[nodiscard]] NXFloat maxY() const;
|
|
|
|
void setWidth(NXFloat newValue);
|
|
void setHeight(NXFloat newValue);
|
|
|
|
void setMinX(NXFloat newValue);
|
|
void setMidX(NXFloat newValue);
|
|
void setMaxX(NXFloat newValue);
|
|
|
|
void setMinY(NXFloat newValue);
|
|
void setMidY(NXFloat newValue);
|
|
void setMaxY(NXFloat newValue);
|
|
|
|
[[nodiscard]] bool contains(NXPoint point) const;
|
|
[[nodiscard]] bool intersects(const NXRect& other) const;
|
|
NXRect& offsetBy(const NXPoint& offset);
|
|
NXRect& offsetBy(const NXFloat& offsetX, const NXFloat& offsetY);
|
|
|
|
bool operator==(const NXRect& rhs) const;
|
|
NXRect operator+(const NXRect& rhs) const;
|
|
NXRect operator-(const NXRect& rhs) const;
|
|
NXRect operator*(const NXFloat& rhs) const;
|
|
|
|
NXRect applying(NXAffineTransform transform);
|
|
NXRect applying(NXTransform3D transform);
|
|
|
|
[[nodiscard]] NXRect intersection(NXRect other) const;
|
|
|
|
[[nodiscard]] bool isNull() const;
|
|
static NXRect null;
|
|
};
|
|
|
|
struct Geometry {
|
|
static NXFloat rubberBandClamp(NXFloat x, NXFloat coeff, NXFloat dim);
|
|
static NXFloat rubberBandClamp(NXFloat x, NXFloat coeff, NXFloat dim, NXFloat limitStart, NXFloat limitEnd);
|
|
};
|
|
|
|
}
|