From: Debian Multimedia Maintainers Date: Fri, 17 Dec 2021 09:37:21 +0000 (+0100) Subject: Patch-in dependency library 'geompp' X-Git-Tag: archive/raspbian/0.21.0-1+rpi1^2~5 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=fc57dec04a2c12e204eac71bba3c262a760bbcdb;p=giada.git Patch-in dependency library 'geompp' Origin: upstream Forwarded: not-needed Last-Update: 2021-08-30 'geompp' is a GPL-3 licensed header-only helper-library by giada-upstream that is only referenced via a gitmodule; we include it via quilt Last-Update: 2021-08-30 Gbp-Pq: Name 02-geompp.patch --- diff --git a/src/deps/geompp/src/border.hpp b/src/deps/geompp/src/border.hpp new file mode 100644 index 0000000..8bc59dc --- /dev/null +++ b/src/deps/geompp/src/border.hpp @@ -0,0 +1,75 @@ +/* ----------------------------------------------------------------------------- + * + * geompp - Basic geometrical utilities for C++. + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories + * + * This file is part of geompp - Basic geometrical utilities for C++. + * + * geompp - Basic geometrical utilities for C++ is free software: you can + * redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * geompp - Basic geometrical utilities for C++ is distributed in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with geompp - Basic geometrical utilities for C++. If not, see + * . + * + * -------------------------------------------------------------------------- */ + +#ifndef GEOMPP_BORDER_HH +#define GEOMPP_BORDER_HH + +namespace geompp +{ +template +class Border +{ +public: + /* Border (1) + Empty border. */ + + constexpr Border() + : Border(0, 0, 0, 0) + { + } + + /* Border (2) + Normal border. */ + + constexpr Border(T t, T r, T b, T l) + : top(t) + , right(r) + , bottom(b) + , left(l) + { + } + + /* Border (3) + Normal border, all sides equal. */ + + constexpr Border(T v) + : Border(v, v, v, v) + { + } + + /* Border (4) + Normal border, horizontal and vertical sides equal. */ + + constexpr Border(T x, T y) + : Border(y, x, y, x) + { + } + + T top, right, bottom, left; +}; +} // namespace geompp + +#endif \ No newline at end of file diff --git a/src/deps/geompp/src/line.hpp b/src/deps/geompp/src/line.hpp new file mode 100644 index 0000000..5ca16fe --- /dev/null +++ b/src/deps/geompp/src/line.hpp @@ -0,0 +1,81 @@ +/* ----------------------------------------------------------------------------- + * + * geompp - Basic geometrical utilities for C++. + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories + * + * This file is part of geompp - Basic geometrical utilities for C++. + * + * geompp - Basic geometrical utilities for C++ is free software: you can + * redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * geompp - Basic geometrical utilities for C++ is distributed in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with geompp - Basic geometrical utilities for C++. If not, see + * . + * + * -------------------------------------------------------------------------- */ + +#ifndef GEOMPP_LINE_HH +#define GEOMPP_LINE_HH + +namespace geompp +{ +template +class Line +{ +public: + /* Line (1) - invalid. */ + + constexpr Line() + : Line(0, 0, 0, 0) + { + } + + /* Line (2) - normal. */ + + constexpr Line(T x1, T y1, T x2, T y2) + : x1(x1) + , y1(y1) + , x2(x2) + , y2(y2) + { + } + + /* shiftX + Horizontally shifts the line of a certain amount. */ + + void shiftX(T amount) + { + x1 += amount; + x2 += amount; + } + + /* with[...] + Returns a copy of this Line with new coordintates. */ + + Line withX1(T v) const { return {v, y1, x2, y2}; } + Line withY1(T v) const { return {x1, v, x2, y2}; } + Line withX2(T v) const { return {x1, y1, v, y2}; } + Line withY2(T v) const { return {x1, y1, x2, v}; } + Line withX(T v) const { return {v, y1, v, y2}; } + Line withY(T v) const { return {x1, v, x2, v}; } + + /* withShiftedX + Returns a new Line horizontally shifted by a certain amount. */ + + Line withShiftedX(T amount) const { return {x1 + amount, y1, x2 + amount, y2}; } + + T x1, y1, x2, y2; +}; +} // namespace geompp + +#endif \ No newline at end of file diff --git a/src/deps/geompp/src/point.hpp b/src/deps/geompp/src/point.hpp new file mode 100644 index 0000000..5b80b6b --- /dev/null +++ b/src/deps/geompp/src/point.hpp @@ -0,0 +1,80 @@ +/* ----------------------------------------------------------------------------- + * + * geompp - Basic geometrical utilities for C++. + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories + * + * This file is part of geompp - Basic geometrical utilities for C++. + * + * geompp - Basic geometrical utilities for C++ is free software: you can + * redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * geompp - Basic geometrical utilities for C++ is distributed in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with geompp - Basic geometrical utilities for C++. If not, see + * . + * + * -------------------------------------------------------------------------- */ + +#ifndef GEOMPP_POINT_HH +#define GEOMPP_POINT_HH + +#include + +namespace geompp +{ +template +class Point +{ +public: + constexpr Point() + : Point(0, 0) + { + } + + constexpr Point(T x, T y) + : x(x) + , y(y) + { + } + + bool operator==(const Point& o) const + { + return x == o.x && y == o.y; + } + + bool operator!=(const Point& o) const + { + return !(*this == o); + } + + Point operator+(const Point& o) const + { + return {x + o.x, y + o.y}; + } + + Point operator-(const Point& o) const + { + return {x - o.x, y - o.y}; + } + + /* with[...] + Returns a copy of this Point with a new coordinate. */ + + Point withX(T v) const { return {v, y}; } + Point withY(T v) const { return {x, v}; } + + T x; + T y; +}; +} // namespace geompp + +#endif diff --git a/src/deps/geompp/src/range.hpp b/src/deps/geompp/src/range.hpp new file mode 100644 index 0000000..1a1e960 --- /dev/null +++ b/src/deps/geompp/src/range.hpp @@ -0,0 +1,76 @@ +/* ----------------------------------------------------------------------------- + * + * geompp - Basic geometrical utilities for C++. + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories + * + * This file is part of geompp - Basic geometrical utilities for C++. + * + * geompp - Basic geometrical utilities for C++ is free software: you can + * redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * geompp - Basic geometrical utilities for C++ is distributed in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with geompp - Basic geometrical utilities for C++. If not, see + * . + * + * -------------------------------------------------------------------------- */ + +#ifndef GEOMPP_RANGE_HH +#define GEOMPP_RANGE_HH + +#include + +namespace geompp +{ +template +class Range +{ +public: + constexpr Range() // Invalid default range + : a(0) + , b(0) + { + } + + constexpr Range(T a, T b) + : a(a) + , b(b) + { + assert(a < b); + } + + Range operator*(const T m) const { return {a * m, b * m}; } + Range operator*=(const T m) const { return {a * m, b * m}; } + Range operator/(const T m) const { return {a / m, b / m}; } + Range operator/=(const T m) const { return {a / m, b / m}; } + Range operator+(const T m) const { return {a + m, b + m}; } + Range operator+=(const T m) const { return {a + m, b + m}; } + Range operator-(const T m) const { return {a - m, b - m}; } + Range operator-=(const T m) const { return {a - m, b - m}; } + + T getLength() const { return b - a; } + + bool isValid() const + { + return a < b; + } + + bool contains(T t) const + { + return t >= a && t < b; + } + + T a, b; +}; +} // namespace geompp + +#endif diff --git a/src/deps/geompp/src/rect.hpp b/src/deps/geompp/src/rect.hpp new file mode 100644 index 0000000..26dc6cf --- /dev/null +++ b/src/deps/geompp/src/rect.hpp @@ -0,0 +1,234 @@ +/* ----------------------------------------------------------------------------- + * + * geompp - Basic geometrical utilities for C++. + * + * ----------------------------------------------------------------------------- + * + * Copyright (C) 2021 Giovanni A. Zuliani | Monocasual Laboratories + * + * This file is part of geompp - Basic geometrical utilities for C++. + * + * geompp - Basic geometrical utilities for C++ is free software: you can + * redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * geompp - Basic geometrical utilities for C++ is distributed in the hope that + * it will be useful, but WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with geompp - Basic geometrical utilities for C++. If not, see + * . + * + * -------------------------------------------------------------------------- */ + +#ifndef GEOMPP_RECT_HH +#define GEOMPP_RECT_HH + +#include "border.hpp" +#include "line.hpp" +#include "point.hpp" +#include "range.hpp" + +namespace geompp +{ +template +class Rect +{ +public: + /* Rect (1) + Invalid rectangle. */ + + constexpr Rect() + : Rect(0, 0, 0, 0) + { + } + + /* Rect (2) + Normal rectangle. */ + + constexpr Rect(T x, T y, T w, T h) + : x(x) + , y(y) + , w(w) + , h(h) + , xw(x + w) + , yh(y + h) + { + } + + void setX(T v) + { + x = v; + xw = x + w; + } + + void setY(T v) + { + y = v; + yh = y + h; + } + + void setW(T v) + { + w = v; + xw = x + w; + } + + void setH(T v) + { + h = v; + yh = y + h; + } + + /* setPosition + Sets the top-left corner to Point 'p'. */ + + void setPosition(Point p) + { + setX(p.x); + setY(p.y); + } + + /* shift[...] + Shifts the rectangle by a certain amount. */ + + void shiftX(T amount) + { + x += amount; + xw = x + w; + } + + void shiftY(T amount) + { + y += amount; + yh = y + h; + } + + /* trim[..] + Removes 'amount' from the one of the edges. */ + + void trimLeft(T amount) + { + x += amount; + w -= amount; + } + + void trimRight(T amount) + { + w -= amount; + xw = x + w; + } + + void trimTop(T amount) + { + y += amount; + h -= amount; + } + + void trimBottom(T amount) + { + h -= amount; + yh = y + h; + } + + /* reduce + Reduces all four sides by a certain Border. */ + + void reduce(Border b) + { + x += b.left; + y += b.top; + w -= b.left + b.right; + h -= b.top + b.bottom; + xw = x + w; + yh = y + h; + } + + /* isValid + True if this Rect has size greater than zero. */ + + bool isValid() const { return w > 0 && h > 0; } + + /* expand (1), (2) + The opposite of reduce (1), (2). */ + + void expand(T amountX, T amountY) { reduce(-amountX, -amountY); } + void expand(T amount) { reduce(-amount); } + + /* with[...] + Returns a copy of this Rect with a new position/size. */ + + Rect withX(T v) const { return {v, y, w, h}; } + Rect withY(T v) const { return {x, v, w, h}; } + Rect withW(T v) const { return {x, y, v, h}; } + Rect withH(T v) const { return {x, y, w, v}; } + + /* withPosition + Returns a copy of this Rect with a new top-left corner given by Point 'p'. */ + + Rect withPosition(Point p) const { return {p.x, p.y, w, h}; } + + /* withShifted[...] + Returns a copy of this Rect shifted by a certain amount. */ + + Rect withShiftedX(T amount) const { return {x + amount, y, w, h}; } + Rect withShiftedY(T amount) const { return {x, y + amount, w, h}; } + + /* withTrimmed[...] + Returns a copy of this Rect with 'amount' removed from the one of the + edges. */ + + Rect withTrimmedLeft(T amount) const { return {x + amount, y, w - amount, h}; } + Rect withTrimmedRight(T amount) const { return {x, y, w - amount, h}; } + Rect withTrimmedTop(T amount) const { return {x, y + amount, w, h - amount}; } + Rect withTrimmedBottom(T amount) const { return {x, y, w, h - amount}; } + + /* get[Width|Height]AsLine + Returns width or height as a new Line object. */ + + Line getWidthAsLine() const { return Line(x, y, xw - 1, y); } + Line getHeightAsLine() const { return Line(x, y, x, yh - 1); } + + Point getPosition() const { return Point(x, y); } + + /* reduced + Returns a copy of this Rect with all four sides reduced by a certain Border. */ + + Rect reduced(Border b) const + { + Rect r = *this; + r.reduce(b); + return r; + } + + /* expanded (1), (2) + The opposite of reduced (1), (2). */ + + Rect expanded(T amountX, T amountY) const { return reduced(-amountX, -amountY); } + Rect expanded(T amount) const { return reduced(-amount); } + + /* contains (1) + Returns true if Point p is inside this Rect. */ + + bool contains(Point p) const + { + return p.x >= x && p.y >= y && p.x < xw && p.y < yh; + } + + /* contains (2) + Returns true if Line l is inside this Rect. */ + + bool contains(Line l) const + { + return l.x1 >= x && l.x1 < xw && l.x2 >= x && l.x2 < xw && + l.y1 >= y && l.y1 < yh && l.y2 >= y && l.y2 < yh; + } + + T x, y, w, h, xw, yh; +}; +} // namespace geompp + +#endif \ No newline at end of file