2 Copyright 2020 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
22 bool Region::overlappedBy(Region& d)
41 Region Region::operator + (Region& other)
45 toReturn.x = (x <= other.x ? x : other.x);
46 toReturn.y = (y <= other.y ? y : other.y);
47 toReturn.w = ((x+w) >= (other.x+other.h) ? (x+w) : (other.x+other.h)) - toReturn.x;
48 toReturn.h = ((y+h) >= (other.y+other.h) ? (y+h) : (other.y+other.h)) - toReturn.y;
53 Region Region::subtract(Region& other)
55 //OK printf("This: %i %i %i %i\n", x, y, w, h);
56 //OK printf("Subtract this: %i %i %i %i\n", other.x, other.y, other.w, other.h);
63 //OK printf("Case 1\n");
69 else if (x2() > other.x2())
71 //OK printf("Case 2\n");
79 //OK printf("Case 3\n");
85 else if (y2() > other.y2())
87 //OK printf("Case 4\n");
100 //OK printf("Result: %i %i %i %i\n", s.x, s.y, s.w, s.h);
106 //i.x = (x >= other.x ? x : other.x);
107 //i.y = (y >= other.y ? y : other.y);
108 //i.w = (x2() <= other.x2() ? x2() : other.x2()) - i.x;
109 //i.h = (y2() <= other.y2() ? y2() : other.y2()) - i.y;