ScummVM API documentation
transform_tools.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRAPHICS_TRANSFORM_TOOLS_H
23 #define GRAPHICS_TRANSFORM_TOOLS_H
24 
25 #include "common/rect.h"
26 #include "graphics/transform_struct.h"
27 
28 namespace Graphics {
29 
30  static const float kEpsilon = 0.00001f; // arbitrarily taken number
31 
32  struct FloatPoint {
33  float x;
34  float y;
35  FloatPoint() : x(0), y(0) {}
36  FloatPoint(float x1, float y1) : x(x1), y(y1) {}
37  FloatPoint(const Common::Point p) : x(p.x), y(p.y) {}
38  bool operator==(const FloatPoint &p) const { return fabs(x - p.x) < kEpsilon && fabs(y - p.y) < kEpsilon; }
39  bool operator!=(const FloatPoint &p) const { return fabs(x - p.x) > kEpsilon || fabs(y - p.y) > kEpsilon; }
40  FloatPoint operator+(const FloatPoint &delta) const { return FloatPoint (x + delta.x, y + delta.y); }
41  FloatPoint operator-(const FloatPoint &delta) const { return FloatPoint (x - delta.x, y - delta.y); }
42 
43  FloatPoint& operator+=(const FloatPoint &delta) {
44  x += delta.x;
45  y += delta.y;
46  return *this;
47  }
48  FloatPoint& operator-=(const FloatPoint &delta) {
49  x -= delta.x;
50  y -= delta.y;
51  return *this;
52  }
53  };
54 
56 public:
65  static FloatPoint transformPoint(FloatPoint point, const float rotate, const Common::Point &zoom, const bool mirrorX = false, const bool mirrorY = false);
66 
72  static Common::Rect newRect(const Common::Rect &oldRect, const TransformStruct &transform, Common::Point *newHotspot);
73 };
74 
75 } // End of namespace Wintermute
76 #endif
Definition: rect.h:144
Definition: transform_tools.h:55
Definition: formatinfo.h:28
Definition: rect.h:45
Definition: transform_tools.h:32
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: transform_struct.h:75