00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00032
00033 #pragma once
00034
00035 #include "../api_core.h"
00036 #include "rect.h"
00037 #include "size.h"
00038 #include "point.h"
00039 #include "origin.h"
00040
00046 template<typename Type>
00047 class CL_API_CORE CL_Quadx
00048 {
00051
00052 public:
00054 CL_Quadx() { }
00055
00062 CL_Quadx(const CL_Vec2<Type> &new_p, const CL_Vec2<Type> &new_q, const CL_Vec2<Type> &new_r, const CL_Vec2<Type> &new_s)
00063 { p = new_p; q = new_q; r = new_r; s = new_s; }
00064
00068 CL_Quadx(const CL_Rectx<Type> &rect)
00069 { p.x = rect.left; p.y = rect.top; q.x = rect.right; q.y = rect.top;
00070 r.x = rect.right; r.y = rect.bottom; s.x = rect.left; s.y = rect.bottom;
00071 }
00072
00076 CL_Quadx(const CL_Quadx<Type> &quad)
00077 { p = quad.p; q = quad.q; r = quad.r; s = quad.s; }
00078
00080 CL_Quadx<Type> &operator+=(const CL_Quadx<Type> &quad)
00081 { p += quad.p; q += quad.q; r += quad.r; s += quad.s; return *this; }
00082
00084 CL_Quadx<Type> &operator-=(const CL_Quadx<Type> &quad)
00085 { p -= quad.p; q -= quad.q; r -= quad.r; s -= quad.s; return *this; }
00086
00088 CL_Quadx<Type> &operator+=(const CL_Vec2<Type> &point)
00089 { p += point; q += point; r += point; s += point; return *this; }
00090
00092 CL_Quadx<Type> &operator-=(const CL_Vec2<Type> &point)
00093 { p -= point; q -= point; r -= point; s -= point; return *this; }
00094
00096 CL_Quadx<Type> operator+(const CL_Quadx<Type> &quad) const
00097 { return CL_Quadx(p + quad.p, q + quad.q, r + quad.r, s + quad.s); }
00098
00100 CL_Quadx<Type> operator-(const CL_Quadx<Type> &quad) const
00101 { return CL_Quadx(p - quad.p, q - quad.q, r - quad.r, s - quad.s); }
00102
00104 CL_Quadx<Type> operator+(const CL_Vec2<Type> &point) const
00105 { return CL_Quadx(p + point, q + point, r + point, s + point); }
00106
00108 CL_Quadx<Type> operator-(const CL_Vec2<Type> &point) const
00109 { return CL_Quadx(p - point, q - point, r - point, s - point); }
00110
00112 bool operator==(const CL_Quadx<Type> &quad) const
00113 { return (p == quad.p && q == quad.q && r == quad.r && s == quad.s); }
00114
00116 bool operator!=(const CL_Quadx<Type> &quad) const
00117 { return (p != quad.p || q != quad.q || r != quad.r || s != quad.s); }
00118
00122
00123 public:
00125 CL_Vec2<Type> p;
00126
00128 CL_Vec2<Type> q;
00129
00131 CL_Vec2<Type> r;
00132
00134 CL_Vec2<Type> s;
00135
00137 Type get_width() const;
00138
00140 Type get_height() const;
00141
00143 CL_Sizex<Type> get_size() const { return CL_Sizex<Type>(get_width(), get_height()); }
00144
00151 CL_Rect get_bounds() const;
00152
00156
00157 public:
00164 CL_Quadx<Type> &rotate(const CL_Vec2<Type> &hotspot, const CL_Angle &angle);
00165
00172 CL_Quadx<Type> &scale(float sx, float sy);
00173
00181 CL_Quadx<Type> &scale(const CL_Vec2<Type> &hotspot, float sx, float sy);
00182
00184 CL_Vec2<Type> center() const;
00185
00192 CL_Quadx<Type> &apply_alignment(CL_Origin origin, Type x, Type y);
00193
00195 };
00196
00200 class CL_Quad : public CL_Quadx<int>
00201 {
00202 public:
00203 CL_Quad() : CL_Quadx<int>() {}
00204 CL_Quad(const CL_Vec2<int> &new_p, const CL_Vec2<int> &new_q, const CL_Vec2<int> &new_r, const CL_Vec2<int> &new_s) : CL_Quadx<int>(new_p, new_q, new_r, new_s) {}
00205 CL_Quad(const CL_Rect &rect) : CL_Quadx<int>(rect) {}
00206 CL_Quad(const CL_Quadx<int> &quad) : CL_Quadx<int>(quad) {}
00207 };
00208
00212 class CL_Quadf : public CL_Quadx<float>
00213 {
00214 public:
00215 CL_Quadf() : CL_Quadx<float>() {}
00216 CL_Quadf(const CL_Vec2<float> &new_p, const CL_Vec2<float> &new_q, const CL_Vec2<float> &new_r, const CL_Vec2<float> &new_s) : CL_Quadx<float>(new_p, new_q, new_r, new_s) {}
00217 CL_Quadf(const CL_Rectf &rect) : CL_Quadx<float>(rect) {}
00218 CL_Quadf(const CL_Quadx<float> &quad) : CL_Quadx<float>(quad) {}
00219 };
00220
00224 class CL_Quadd : public CL_Quadx<double>
00225 {
00226 public:
00227 CL_Quadd() : CL_Quadx<double>() {}
00228 CL_Quadd(const CL_Vec2<double> &new_p, const CL_Vec2<double> &new_q, const CL_Vec2<double> &new_r, const CL_Vec2<double> &new_s) : CL_Quadx<double>(new_p, new_q, new_r, new_s) {}
00229 CL_Quadd(const CL_Rectd &rect) : CL_Quadx<double>(rect) {}
00230 CL_Quadd(const CL_Quadx<double> &quad) : CL_Quadx<double>(quad) {}
00231 };
00232