Foxit PDF SDK
fx_coordinates.h
Go to the documentation of this file.
1 
15 //<<<+++OPENSOURCE
16 //<<<+++OPENSOURCE_LICENSE
17 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
18 
24 //<<<+++OPENSOURCE_MUST_BEGIN
25 #ifndef _FXCRT_COORDINATES_
26 #define _FXCRT_COORDINATES_
27 //<<<+++OPENSOURCE_MUST_END
28 
29 //internal classes
30 template<class baseType> class CFX_PSVTemplate;
31 template<class baseType> class CFX_VTemplate;
32 template<class baseType> class CFX_PRLTemplate;
33 template<class baseType> class CFX_RTemplate;
34 template<class baseType> class CFX_ETemplate;
35 template<class baseType> class CFX_ATemplate;
36 template<class baseType> class CFX_RRTemplate;
37 class CFX_Matrix;
38 
39 //*****************************************************************************
40 //* Point/Size
41 //*****************************************************************************
43 template<class BaseType>
44 class CFX_PSVTemplate : public CFX_Object
45 {
46  public:
47  typedef CFX_PSVTemplate<BaseType> FXT_PSV;
48 // typedef CFX_PSVTemplate<baseType> FXT_POINT;
49 // typedef CFX_PSVTemplate<baseType> FXT_SIZE;
50 
52  CFX_PSVTemplate() : x(0), y(0) {}
59  CFX_PSVTemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {}
61  CFX_PSVTemplate(const CFX_PSVTemplate& other) : x(other.x), y(other.y) {}
62 
71  void Set(BaseType x, BaseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
79  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
88  void Add(BaseType x, BaseType y) {FXT_PSV::x += x, FXT_PSV::y += y;}
97  void Subtract(BaseType x, BaseType y) {FXT_PSV::x -= x, FXT_PSV::y -= y;}
103  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
104 
112  FXT_PSV& operator += (const FXT_PSV &obj) {x += obj.x; y += obj.y; return *this;}
120  FXT_PSV& operator -= (const FXT_PSV &obj) {x -= obj.x; y -= obj.y; return *this;}
128  FXT_PSV& operator *= (BaseType lamda) {x *= lamda; y *= lamda; return *this;}
136  FXT_PSV& operator /= (BaseType lamda) {x /= lamda; y /= lamda; return *this;}
137 
146  friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x == obj2.x && obj1.y == obj2.y;}
155  friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x != obj2.x || obj1.y != obj2.y;}
164  friend FXT_PSV operator + (const FXT_PSV &obj1, const FXT_PSV &obj2) {CFX_PSVTemplate obj; obj.x = obj1.x + obj2.x; obj.y = obj1.y + obj2.y; return obj;}
173  friend FXT_PSV operator - (const FXT_PSV &obj1, const FXT_PSV &obj2) {CFX_PSVTemplate obj; obj.x = obj1.x - obj2.x; obj.y = obj1.y - obj2.y; return obj;}
182  friend FXT_PSV operator * (const FXT_PSV &obj, BaseType lamda) {CFX_PSVTemplate t; t.x = obj.x * lamda; t.y = obj.y * lamda; return t;}
191  friend FXT_PSV operator * (BaseType lamda, const FXT_PSV &obj) {CFX_PSVTemplate t; t.x = lamda * obj.x; t.y = lamda * obj.y; return t;}
200  friend FXT_PSV operator / (const FXT_PSV &obj, BaseType lamda) {CFX_PSVTemplate t; t.x = obj.x / lamda; t.y = obj.y / lamda; return t;}
201 
203  BaseType x;
205  BaseType y;
206 };
227 
228 //Keep old symbol
229 #define CFX_FloatPoint CFX_PointF
230 
232 template<class baseType>
233 class CFX_VTemplate: public CFX_PSVTemplate<baseType>
234 {
235  public:
236  typedef CFX_PSVTemplate<baseType> FXT_PSV;
237  typedef CFX_PSVTemplate<baseType> FXT_POINT;
238  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
239  typedef CFX_VTemplate<baseType> FXT_VECTOR;
240 
241  void Set(baseType x, baseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
242  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
243  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;}
244  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
245 
246  baseType SquareLength() const {return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;}
247  baseType Length() const {return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);}
248  void Normalize()
249  {
251  FXSYS_assert(fLen >= 0.0001f);
252  if (fLen < 0.0001f)
253  return;
254  FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
255  FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
256  }
257  baseType DotProduct(baseType x, baseType y) const {return FXT_PSV::x * x + FXT_PSV::y * y;}
258  baseType DotProduct(const FXT_VECTOR &v) const {return FXT_PSV::x * v.x + FXT_PSV::y * v.y;}
259  FX_BOOL IsParallel(baseType x, baseType y) const {baseType t = FXT_PSV::x * y - FXT_PSV::y * x; return FXSYS_fabs(t) < 0.0001f;}
260  FX_BOOL IsParallel(const FXT_VECTOR &v) const {return IsParallel(v.x, v.y);}
261  FX_BOOL IsPerpendicular(baseType x, baseType y) const {baseType t = DotProduct(x, y); return FXSYS_fabs(t) < 0.0001f;}
262  FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const {return IsPerpendicular(v.x, v.y);}
263 
264  void Translate(baseType dx, baseType dy) {FXT_PSV::x += dx, FXT_PSV::y += dy;}
265  void Scale(baseType sx, baseType sy) {FXT_PSV::x *= sx, FXT_PSV::y *= sy;}
266  void Rotate(FX_FLOAT fRadian)
267  {
270  FX_FLOAT cosValue = FXSYS_cos(fRadian);
271  FX_FLOAT sinValue = FXSYS_sin(fRadian);
272  FXT_PSV::x = xx * cosValue - yy * sinValue;
273  FXT_PSV::y = xx * sinValue + yy * cosValue;
274  }
275 
276  friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
277  {
278  FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
279  FX_FLOAT dotProduct = v1.DotProduct(v2);
280  return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
281  }
282  friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
283  {
284  return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
285  }
286  friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
287  {
288  CFX_VTemplate vx;
289  vx.Set(1, 0);
290  FX_FLOAT fSlope = ArcCosine(v, vx);
291  return v.y < 0 ? -fSlope : fSlope;
292  }
293 };
294 
299 
301 template<class baseType>
302 class CFX_PRLTemplate: public CFX_Object
303 {
304  public:
305  typedef CFX_PSVTemplate<baseType> FXT_POINT;
306  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
307  typedef CFX_VTemplate<baseType> FXT_VECTOR;
308  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
309 
310  void Set(baseType x, baseType y, baseType x1, baseType y1, baseType x2, baseType y2) {FXT_PARAL::x = x, FXT_PARAL::y = y, FXT_PARAL::x1 = x1, FXT_PARAL::y1 = y1, FXT_PARAL::x2 = x2, FXT_PARAL::y2 = y2;}
311  void Set(const FXT_POINT &p, const FXT_VECTOR &v1, const FXT_VECTOR &v2) {FXT_PARAL::P(p), FXT_PARAL::V1(v1), FXT_PARAL::V2(v2);}
312  void Reset() {FXT_PARAL::x = FXT_PARAL::y = FXT_PARAL::x1 = FXT_PARAL::y1 = FXT_PARAL::x2 = FXT_PARAL::y2 = 0;}
313 
314  CFX_PRLTemplate& operator += (const FXT_POINT &p) {x += p.x; y += p.y; return *this;}
315  CFX_PRLTemplate& operator -= (const FXT_POINT &p) {x -= p.x; y -= p.y; return *this;}
316 
317  FXT_POINT P() const {FXT_POINT p; p.x = x, p.y = y; return p;}
318  void P(FXT_POINT p) {x = p.x, y = p.y;}
319  FXT_VECTOR V1() const {FXT_VECTOR v; v.x = x1, v.y = y1; return v;}
320  void V1(FXT_VECTOR v) {x1 = v.x, y1 = v.y;}
321  FXT_VECTOR V2() const {FXT_VECTOR v; v.x = x2, v.y = y2; return v;}
322  void V2(FXT_VECTOR v) {x2 = v.x, y2 = v.y;}
323 
324  FX_BOOL IsEmpty() const {return V1().IsParallel(x2, y2);}
325  FX_BOOL IsRect() const {return V1().IsPerpendicular(x2, y2);}
326  FXT_SIZE Size() const {FXT_SIZE s; s.x = V1().Length(); s.y = V2().Length(); return s;}
327  FXT_POINT Center() const {return (V1() + V2()) / 2 + P();}
328  FXT_POINT P1() const {return P();}
329  FXT_POINT P2() const {return P() + V1();}
330  FXT_POINT P3() const {return P() + V1() + V2();}
331  FXT_POINT P4() const {return P() + V2();}
332 
333  baseType x, y;
334  baseType x1, y1;
335  baseType x2, y2;
336 };
337 
342 //<<<+++OPENSOURCE_MUST_END
343 
345 template<class baseType>
346 class CFX_RTemplate: public CFX_Object
347 {
348  public:
349  typedef CFX_PSVTemplate<baseType> FXT_POINT;
350  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
351  typedef CFX_VTemplate<baseType> FXT_VECTOR;
352  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
353  typedef CFX_RTemplate<baseType> FXT_RECT;
354 
355  void Set(baseType left, baseType top, baseType width, baseType height) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;}
356  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
357  void Set(const FXT_POINT &p, baseType width, baseType height) {TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
358  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();}
359  void Set(const FXT_POINT &p, const FXT_VECTOR &v) {TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();}
360  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
361 
362  FXT_RECT& operator += (const FXT_POINT &p) {left += p.x, top += p.y; return *this;}
363  FXT_RECT& operator -= (const FXT_POINT &p) {left -= p.x, top -= p.y; return *this;}
364 
365  baseType right() const {return left + width;}
366  baseType bottom() const {return top + height;}
367  void Normalize() {if (width < 0) {left += width; width = -width;} if (height < 0) {top += height; height = -height;}}
368  void Offset(baseType dx, baseType dy) {left += dx; top += dy;}
369  void Inflate(baseType x, baseType y) {left -= x; width += x * 2; top -= y; height += y * 2;}
370  void Inflate(const FXT_POINT &p) {Inflate(p.x, p.y);}
371  void Inflate(baseType left, baseType top, baseType right, baseType bottom) {FXT_RECT::left -= left; FXT_RECT::top -= top; FXT_RECT::width += left + right; FXT_RECT::height += top + bottom;}
372  void Inflate(const FXT_RECT &rt) {Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);}
373  void Deflate(baseType x, baseType y) {left += x; width -= x * 2; top += y; height -= y * 2;}
374  void Deflate(const FXT_POINT &p) {Deflate(p.x, p.y);}
375  void Deflate(baseType left, baseType top, baseType right, baseType bottom) {FXT_RECT::left += left; FXT_RECT::top += top; FXT_RECT::width -= left + right; FXT_RECT::height -= top + bottom;}
376  void Deflate(const FXT_RECT &rt) {Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);}
377  FX_BOOL IsEmpty() const {return width <= 0 || height <= 0;}
378  FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const {return width <= fEpsilon || height <= fEpsilon;}
379  void Empty() {width = height = 0;}
380  FX_BOOL Contains(baseType x, baseType y) const {return x >= left && x < left + width && y >= top && y < top + height;}
381  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
382  FX_BOOL Contains(const FXT_RECT &rt) const {return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();}
383  baseType Width() const {return width;}
384  baseType Height() const {return height;}
385  FXT_SIZE Size() const {FXT_SIZE size; size.Set(width, height); return size;}
386  void Size(FXT_SIZE s) {width = s.x, height = s.y;}
387  FXT_POINT TopLeft() const {FXT_POINT p; p.x = left; p.y = top; return p;}
388  FXT_POINT TopRight() const {FXT_POINT p; p.x = left + width; p.y = top; return p;}
389  FXT_POINT BottomLeft() const {FXT_POINT p; p.x = left; p.y = top + height; return p;}
390  FXT_POINT BottomRight() const {FXT_POINT p; p.x = left + width; p.y = top + height; return p;}
391  void TopLeft(FXT_POINT tl) {left = tl.x; top = tl.y;}
392  void TopRight(FXT_POINT tr) {width = tr.x - left; top = tr.y;}
393  void BottomLeft(FXT_POINT bl) {left = bl.x; height = bl.y - top;}
394  void BottomRight(FXT_POINT br) {width = br.x - left; height = br.y - top;}
395  FXT_POINT Center() const {FXT_POINT p; p.x = left + width / 2; p.y = top + height / 2; return p;}
396 
397  void GetParallelogram(FXT_PARAL &pg) const {pg.x = left, pg.y = top; pg.x1 = width, pg.y1 = 0; pg.x2 = 0, pg.y2 = height;}
398 
399  void Union(baseType x, baseType y)
400  {
401  baseType r = right(), b = bottom();
402  if (left > x) left = x;
403  if (r < x) r = x;
404  if (top > y) top = y;
405  if (b < y) b = y;
406  width = r - left;
407  height = b - top;
408  }
409  void Union(const FXT_POINT &p) {Union(p.x, p.y);}
410  void Union(const FXT_RECT &rt)
411  {
412  baseType r = right(), b = bottom();
413  if (left > rt.left) left = rt.left;
414  if (r < rt.right()) r = rt.right();
415  if (top > rt.top) top = rt.top;
416  if (b < rt.bottom()) b = rt.bottom();
417  width = r - left;
418  height = b - top;
419  }
420  void Intersect(const FXT_RECT &rt)
421  {
422  baseType r = right(), b = bottom();
423  if (left < rt.left) left = rt.left;
424  if (r > rt.right()) r = rt.right();
425  if (top < rt.top) top = rt.top;
426  if (b > rt.bottom()) b = rt.bottom();
427  width = r - left;
428  height = b - top;
429  }
430  FX_BOOL IntersectWith(const FXT_RECT &rt) const
431  {
432  FXT_RECT rect = rt;
433  rect.Intersect(*this);
434  return !rect.IsEmpty();
435  }
436  FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
437  {
438  FXT_RECT rect = rt;
439  rect.Intersect(*this);
440  return !rect.IsEmpty(fEpsilon);
441  }
442 
443  friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) {return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height;}
444  friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) {return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height;}
445 
446  baseType left, top;
447  baseType width, height;
448 };
449 
464 
466 template<class baseType>
467 class CFX_ETemplate : public CFX_RTemplate<baseType>
468 {
469  public:
470  typedef CFX_PSVTemplate<baseType> FXT_POINT;
471  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
472  typedef CFX_VTemplate<baseType> FXT_VECTOR;
473  typedef CFX_RTemplate<baseType> FXT_RECT;
474 
475  void Set(baseType left, baseType top, baseType width, baseType height) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height;}
476  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
477  void Set(const FXT_POINT &p, baseType width, baseType height) {FXT_RECT::TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
478  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {FXT_RECT::TopLeft(p1), FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RECT::Normalize();}
479  void Set(const FXT_POINT &p, const FXT_VECTOR &v) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RECT::Normalize();}
480  void SetRadius(const FXT_POINT &p, baseType xRadius, baseType yRadius) {FXT_RECT::left = p.x - xRadius, FXT_RECT::top = p.y - yRadius, FXT_RECT::width = xRadius * 2, FXT_RECT::height = yRadius * 2;}
481  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
482 
483  FX_BOOL Contains(baseType x, baseType y) const
484  {
485  x -= FXT_RECT::left + FXT_RECT::width / 2;
486  y -= FXT_RECT::top + FXT_RECT::height / 2;
487  return ((FX_FLOAT)(x * x) / (FX_FLOAT)(FXT_RECT::width * FXT_RECT::width) + (FX_FLOAT)(y * y) / (FX_FLOAT)(FXT_RECT::height * FXT_RECT::height)) <= 0.25f;
488  }
489  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
490  FX_BOOL Contains(const FXT_RECT &rt) const {return Contains(rt.TopLeft()) && Contains(rt.BottomRight());}
491 
492  baseType XRadius() const {return FXT_RECT::width / 2;}
493  baseType YRadius() const {return FXT_RECT::height / 2;}
494 
495  void GetPointF(FX_FLOAT fRadian, CFX_PointF &point) const
496  {
497  FX_FLOAT a = (FX_FLOAT)FXT_RECT::width / 2.0f;
498  FX_FLOAT b = (FX_FLOAT)FXT_RECT::height / 2.0f;
499  FX_FLOAT sinValue = (FX_FLOAT)FXSYS_sin(fRadian);
500  FX_FLOAT cosValue = (FX_FLOAT)FXSYS_cos(fRadian);
501  FX_FLOAT d = FXSYS_sqrt(b * b * cosValue * cosValue + a * a * sinValue * sinValue);
502  fRadian = a * b;
503  point.x = fRadian * cosValue / d + FXT_RECT::left + a;
504  point.y = fRadian * sinValue / d + FXT_RECT::top + b;
505  }
506  void GetPoint(FX_FLOAT fRadian, CFX_Point &point) const
507  {
508  CFX_PointF p;
509  GetPointF(fRadian, p);
510  point.x = FXSYS_round(p.x + 0.5f);
511  point.y = FXSYS_round(p.y + 0.5f);
512  }
513 };
514 
519 
521 template<class baseType>
522 class CFX_RRTemplate: public CFX_RTemplate<baseType>
523 {
524  public:
525  typedef CFX_PSVTemplate<baseType> FXT_POINT;
526  typedef CFX_VTemplate<baseType> FXT_VECTOR;
527  typedef CFX_RTemplate<baseType> FXT_RECT;
528  typedef CFX_RRTemplate<baseType> FXT_RRECT;
529 
530  void Set(baseType left, baseType top, baseType width, baseType height, baseType xRadius, baseType yRadius) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius;}
531  void Set(const FXT_POINT &p1, const FXT_POINT &p2, baseType xRadius, baseType yRadius) {FXT_RECT::left = p1.x, FXT_RECT::top = p1.y, FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius, FXT_RECT::Normalize();}
532  void Set(const FXT_POINT &p, const FXT_VECTOR &v, baseType xRadius, baseType yRadius) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius, FXT_RECT::Normalize();}
533  void Set(const FXT_RECT &rt, baseType xRadius, baseType yRadius) {FXT_RECT::left = rt.left, FXT_RECT::top = rt.top, FXT_RECT::width = rt.width, FXT_RECT::height = rt.height, FXT_RRECT::xRadius = xRadius, FXT_RRECT::yRadius = yRadius;}
534  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_RRECT));}
535 
537  baseType xRadius;
539  baseType yRadius;
540 };
541 
546 
548 template<class baseType>
549 class CFX_ATemplate: public CFX_ETemplate<baseType>
550 {
551  public:
552  typedef CFX_PSVTemplate<baseType> FXT_POINT;
553  typedef CFX_VTemplate<baseType> FXT_VECTOR;
554  typedef CFX_RTemplate<baseType> FXT_RECT;
555  typedef CFX_ETemplate<baseType> FXT_ELLIPSE;
556  typedef CFX_ATemplate<baseType> FXT_ARC;
557 
558  void Set(baseType left, baseType top, baseType width, baseType height, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::width = width, FXT_RECT::height = height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
559  void Set(const FXT_POINT &p1, const FXT_POINT &p2, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = p1.x, FXT_RECT::top = p1.y, FXT_RECT::width = p2.x - p1.x, FXT_RECT::height = p2.y - p1.y, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle, FXT_RECT::Normalize();}
560  void Set(const FXT_POINT &p, const FXT_VECTOR &v, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::TopLeft(p), FXT_RECT::width = v.x, FXT_RECT::height = v.y, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle, FXT_RECT::Normalize();}
561  void Set(const FXT_POINT &p, baseType xRadius, baseType yRadius, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = p.x - xRadius, FXT_RECT::top = p.y - yRadius, FXT_RECT::width = xRadius * 2, FXT_RECT::height = yRadius * 2, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
562  void Set(const FXT_RECT &rt, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_RECT::left = rt.left, FXT_RECT::top = rt.top, FXT_RECT::width = rt.width, FXT_RECT::height = rt.height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
563  void Set(const FXT_ELLIPSE &ellipse, FX_FLOAT startAngle, FX_FLOAT sweepAngle) {FXT_ELLIPSE::left = ellipse.left, FXT_RECT::top = ellipse.top, FXT_RECT::width = ellipse.width, FXT_RECT::height = ellipse.height, FXT_ARC::startAngle = startAngle, FXT_ARC::sweepAngle = sweepAngle;}
564  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_ARC));}
565 
566  FX_FLOAT EndAngle() const {return startAngle + sweepAngle;}
567  void EndAngle(FX_FLOAT endAngle) {sweepAngle = endAngle - startAngle;}
568  void StartPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(startAngle, point);}
569  void EndPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(EndAngle(), point);}
570  void StartPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(startAngle, point);}
571  void EndPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(EndAngle(), point);}
572 
577 };
578 
583 //<<<+++OPENSOURCE_END
584 
590 struct FX_RECT
591 {
593  int left;
595  int top;
597  int right;
599  int bottom;
600 
605  left = 0;
606  top = 0;
607  right = 0;
608  bottom = 0;
609  }
610 
619  FX_RECT(int left1, int top1, int right1, int bottom1)
620  { left = left1; top = top1; right = right1; bottom = bottom1; }
621 
627  int Width() const { return right - left; }
628 
634  int Height() const { return bottom - top; }
635 
641  FX_BOOL IsEmpty() const { return right <= left || bottom <= top; }
642 
648  void Normalize();
649 
657  void Intersect(const FX_RECT& src);
658 
669  void Intersect(int left1, int top1, int right1, int bottom1) { Intersect(FX_RECT(left1, top1, right1, bottom1)); }
670 
678  void Union(const FX_RECT& other_rect);
679 
687  FX_BOOL operator == (const FX_RECT& src) const
688  { return left == src.left && right == src.right && top == src.top && bottom == src.bottom; }
689 
697  FX_BOOL operator != (const FX_RECT& src) const
698  { return left != src.left || right != src.right || top != src.top || bottom != src.bottom; }
699 
708  void Offset(int dx, int dy) { left += dx; right += dx; top += dy; bottom += dy; }
709 
718  FX_BOOL Contains(const FX_RECT& other_rect) const
719  {
720  // Assume both rects are normalized!
721  return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
722  }
723 
733  FX_BOOL Contains(int x, int y) const
734  {
735  // Assume the rectangle is normalized!
736  return x >= left && x < right && y >= top && y < bottom;
737  }
738 
744  FX_BOOL Valid() const;
745 };
746 
751 {
760 };
761 
766 class CFX_FloatRect : public CFX_Object
767 {
768  public:
772  CFX_FloatRect() { left = right = bottom = top = 0; }
773 
782  CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
783  { left = left1; bottom = bottom1; right = right1; top = top1; }
789  CFX_FloatRect(const FX_FLOAT* pArray)
790  { left = pArray[0]; bottom = pArray[1]; right = pArray[2]; top = pArray[3]; }
791 
797  CFX_FloatRect(const FX_RECT& rect);
798 
804  FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
805 
811  void Normalize();
812 
821  { return FXSYS_fabs(left - src.left) < FLT_EPSILON && FXSYS_fabs(right - src.right) < FLT_EPSILON &&
822  FXSYS_fabs(top - src.top) < FLT_EPSILON && FXSYS_fabs(bottom - src.bottom) < FLT_EPSILON; }
823 
832  { return FXSYS_fabs(left - src.left) > FLT_EPSILON || FXSYS_fabs(right - src.right) > FLT_EPSILON ||
833  FXSYS_fabs(top - src.top) > FLT_EPSILON || FXSYS_fabs(bottom - src.bottom) > FLT_EPSILON; }
834 
840  void Reset() {left = right = bottom = top = 0;}
841 
850  FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
851 
861  FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
862 
870  void Transform(const CFX_Matrix* pMatrix);
871 
879  void Intersect(const CFX_FloatRect& other_rect);
880 
888  void Union(const CFX_FloatRect& other_rect);
889 
895  FX_RECT GetInnerRect() const;
896 
902  FX_RECT GetOutterRect() const;
903 
909  FX_RECT GetClosestRect() const;
910 
920  int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
921 
930  void InitRect(FX_FLOAT x, FX_FLOAT y) { left = right = x; bottom = top = y; }
931 
940  void UpdateRect(FX_FLOAT x, FX_FLOAT y);
941 
947  FX_FLOAT Width() const { return right - left; }
948 
954  FX_FLOAT Height() const { return top - bottom; }
955 
964  void Inflate(FX_FLOAT x, FX_FLOAT y) { Inflate(x, y, x, y); }
975  void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top) {Normalize(); this->left -= left; this->bottom -= bottom; this->right += right; this->top += top;}
976 
984  void Inflate(const CFX_FloatRect &rt) {Inflate(rt.left, rt.bottom, rt.right, rt.top);}
985 
994  void Deflate(FX_FLOAT x, FX_FLOAT y) { Deflate(x, y, x, y); }
1013  void Deflate(const CFX_FloatRect &rt) {Deflate(rt.left, rt.bottom, rt.right, rt.top);}
1014 
1023  void Translate(FX_FLOAT e, FX_FLOAT f) {left += e; right += e; top += f; bottom += f;}
1024 
1033  static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
1034 
1043 };
1044 
1047 
1056 class CFX_Matrix : public CFX_Object
1057 {
1058  public:
1062  CFX_Matrix() {a = d = 1; b = c = e = f = 0;}
1063 
1075  {a = a1; b = b1; c = c1; d = d1; e = e1; f = f1;}
1076 
1084  FX_BOOL operator == (const CFX_Matrix& src) const
1085  { return FXSYS_fabs(a - src.a) < FLT_EPSILON && FXSYS_fabs(b - src.b) < FLT_EPSILON &&
1086  FXSYS_fabs(c - src.c) < FLT_EPSILON && FXSYS_fabs(d - src.d) < FLT_EPSILON &&
1087  FXSYS_fabs(e - src.e) < FLT_EPSILON && FXSYS_fabs(f - src.f) < FLT_EPSILON; }
1088 
1096  FX_BOOL operator != (const CFX_Matrix& src) const
1097  { return FXSYS_fabs(a - src.a) > FLT_EPSILON || FXSYS_fabs(b - src.b) > FLT_EPSILON ||
1098  FXSYS_fabs(c - src.c) > FLT_EPSILON || FXSYS_fabs(d - src.d) > FLT_EPSILON ||
1099  FXSYS_fabs(e - src.e) > FLT_EPSILON || FXSYS_fabs(f - src.f) > FLT_EPSILON; }
1100 
1114 
1122  void Set(const FX_FLOAT n[6]);
1123 
1129  void SetIdentity() {a = d = 1; b = c = e = f = 0;}
1130 
1138  void SetReverse(const CFX_Matrix &m);
1139 
1153  void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = false);
1162  void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = false);
1171  void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = false);
1177  void Reset() {SetIdentity();}
1178 
1186  void Copy(const CFX_Matrix& m) {*this = m;}
1187 
1193  FX_BOOL IsIdentity() const {return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;}
1194 
1200  FX_BOOL IsInvertible() const;
1201 
1207  FX_BOOL Is90Rotated() const;
1208 
1214  FX_BOOL IsScaled() const;
1215 
1225  void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = false);
1235  void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended = false) {Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);}
1245  void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = false);
1254  void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = false);
1265  void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = false);
1275  void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = false);
1276 
1285  void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
1286 
1292  FX_FLOAT GetXUnit() const;
1293 
1299  FX_FLOAT GetYUnit() const;
1300 
1308  void GetUnitParallelogram(CFX_ParallelogramF &pg) const;
1316  void GetUnitRect(CFX_RectF &rect) const;
1322  CFX_FloatRect GetUnitRect() const;
1328  FX_FLOAT GetUnitArea() const;
1329 
1330 #ifdef _FXGE_IMAGERENDER_SHORTCUT_
1331  const FX_INT32 GetRotation() const;
1332  const FX_BOOL NeedTransform() const;
1333 #endif
1334 
1391  FX_FLOAT TransformDistance(FX_FLOAT distance) const;
1392 
1401  void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
1410  void TransformPoint(FX_INT32 &x, FX_INT32 &y) const;
1419  void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const;
1428  void TransformPoints(CFX_Point *points, FX_INT32 iCount) const;
1429 
1438  void Transform(FX_FLOAT& x, FX_FLOAT& y) const {TransformPoint(x, y);}
1439 
1450  void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const {x1 = x, y1 = y; TransformPoint(x1, y1);}
1451 
1459  void TransformVector(CFX_VectorF &v) const;
1467  void TransformVector(CFX_Vector &v) const;
1468 
1484  void TransformParallelogram(CFX_Parallelogram &pg) const;
1485 
1493  void TransformRect(CFX_RectF &rect) const;
1501  void TransformRect(CFX_Rect &rect) const;
1502 
1513  void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
1521  void TransformRect(CFX_FloatRect& rect) const {TransformRect(rect.left, rect.right, rect.top, rect.bottom);}
1529  void TransformRect(FX_RECT& rect) const;
1530 
1538  void TransformRoundRect(CFX_RoundRectF &rr) const;
1546  void TransformRoundRect(CFX_RoundRect &rr) const;
1547 
1553  FX_FLOAT GetA() const {return a;}
1554 
1560  FX_FLOAT GetB() const {return b;}
1561 
1567  FX_FLOAT GetC() const {return c;}
1568 
1574  FX_FLOAT GetD() const {return d;}
1575 
1581  FX_FLOAT GetE() const {return e;}
1582 
1588  FX_FLOAT GetF() const {return f;}
1589 
1590  public:
1603 };
1604 
1605 class CFX_Vector_3by1 : public CFX_Object
1606 {
1607  public:
1608 CFX_Vector_3by1():
1609  a(0.0f),
1610  b(0.0f),
1611  c(0.0f)
1612  {}
1613  CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1):
1614  a(a1),
1615  b(b1),
1616  c(c1)
1617  {}
1618  FX_FLOAT a;
1619  FX_FLOAT b;
1620  FX_FLOAT c;
1621 };
1622 
1623 class CFX_Matrix_3by3 : public CFX_Object
1624 {
1625  public:
1626 CFX_Matrix_3by3():a(0.0f), b(0.0f), c(0.0f), d(0.0f), e(0.0f), f(0.0f), g(0.0f), h(0.0f), i(0.0f)
1627  {}
1628 
1629  CFX_Matrix_3by3(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1, FX_FLOAT g1, FX_FLOAT h1, FX_FLOAT i1) :
1630  a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1)
1631  {}
1632  CFX_Matrix_3by3 Inverse();
1633  CFX_Matrix_3by3 Multiply(const CFX_Matrix_3by3 &m);
1634  CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1 &v) const;
1635  FX_FLOAT a;
1636  FX_FLOAT b;
1637  FX_FLOAT c;
1638  FX_FLOAT d;
1639  FX_FLOAT e;
1640  FX_FLOAT f;
1641  FX_FLOAT g;
1642  FX_FLOAT h;
1643  FX_FLOAT i;
1644 };
1645 
1646 //Keep old symbol
1647 #define CFX_AffineMatrix CFX_Matrix
1648 
1649 //<<<+++OPENSOURCE_MUST_BEGIN
1650 #endif //_FXCRT_COORDINATES_
1651 //<<<+++OPENSOURCE_MUST_END
1652 
1655 //<<<+++OPENSOURCE_END
CFX_PSVTemplate(BaseType new_x, BaseType new_y)
Constructor, with parameters.
Definition: fx_coordinates.h:59
int top
The top.
Definition: fx_coordinates.h:595
FX_BOOL Valid() const
Check if current rectangle is valid.
CFX_PRLTemplate< FX_INT32 > CFX_Parallelogram
Type definition for parallelogram class for integer.
Definition: fx_coordinates.h:339
CFX_PSVTemplate()
Constructor.
Definition: fx_coordinates.h:52
void Set(BaseType x, BaseType y)
Set values.
Definition: fx_coordinates.h:71
static CFX_FloatRect GetBBox(const CFX_PointF *pPoints, int nPoints)
Get the bounding box of input points array.
FX_RECT GetOutterRect() const
Convert to an outer integer rectangle.
int bottom
The bottom.
Definition: fx_coordinates.h:599
void Normalize()
Normalize the rect. Make sure left <= right, top <= bottom.
int Width() const
Get the width of the rect.
Definition: fx_coordinates.h:627
void Intersect(int left1, int top1, int right1, int bottom1)
Intersect with a rect.
Definition: fx_coordinates.h:669
CFX_ArrayTemplate< CFX_FloatRect > CFX_RectArray
Rectangle array.
Definition: fx_coordinates.h:1046
void TransformRect(CFX_FloatRect &rect) const
Transform a rectangle and return a bounding rectangle. The result rectangle is always normalized: lef...
Definition: fx_coordinates.h:1521
void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const
Transform a point.
void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended=false)
Translate the matrix. using integer value.
Definition: fx_coordinates.h:1235
int Height() const
Get the height of the rect.
Definition: fx_coordinates.h:634
void TransformVector(CFX_VectorF &v) const
Transform a vector.
void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT &x1, FX_FLOAT &y1) const
Transform a point.
Definition: fx_coordinates.h:1450
FX_RECT GetClosestRect() const
Get a closest integer rectangle.
BaseType x
x coordinate of the point.
Definition: fx_coordinates.h:203
FX_BOOL Contains(const FX_RECT &other_rect) const
Check if current rectangle fully contains the other provided rectangle. That means to check if the ot...
Definition: fx_coordinates.h:718
CFX_ArrayTemplate< CFX_RectF > CFX_RectFArray
Type definition for rect array.
Definition: fx_coordinates.h:463
FX_RECT(int left1, int top1, int right1, int bottom1)
Construct a rect with left-top and right bottom corners.
Definition: fx_coordinates.h:619
int FXSYS_round(FX_FLOAT f)
Get nearest integer.
FX_FLOAT TransformYDistance(FX_FLOAT dy) const
Transform a y-distance.
CFX_RTemplate< FX_FLOAT > * FX_LPRECTF
Type definition for pointer to float rectangle.
Definition: fx_coordinates.h:457
CFX_ArrayTemplate< CFX_PointF > CFX_PointsF
Type definition for float point array.
Definition: fx_coordinates.h:218
FX_FLOAT b
The coefficient b.
Definition: fx_coordinates.h:1594
void Reset()
Reset current matrix.
Definition: fx_coordinates.h:1177
void Normalize()
Normalize the rect. Make sure left <= right, and bottom <= top.
CFX_RRTemplate< FX_FLOAT > CFX_RoundRectF
Type definition for round-corner rectangle class for float.
Definition: fx_coordinates.h:545
void TransformRect(CFX_RectF &rect) const
Transform a rectangle and return a bounding rectangle. The result rectangle is always normalized: lef...
CFX_ArrayTemplate< CFX_Point > CFX_Points
Type definition for integer point array.
Definition: fx_coordinates.h:216
void Union(const FX_RECT &other_rect)
Union with a rect.
void Inflate(const CFX_FloatRect &rt)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:984
Definition: fx_coordinates.h:30
FX_FLOAT sweepAngle
Sweep angle to draw arc. Positive is counterclockwise from starting angle, in radian.
Definition: fx_coordinates.h:576
void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended=false)
Concatenate with another matrix.
#define FXSYS_sin
Calculate the sine of a floating-point number from a radian argument.
Definition: fx_system.h:1427
FX_BOOL IsScaled() const
Whether this matrix has scaling (or translating) only. No rotating.
CFX_PRLTemplate< FX_FLOAT > CFX_ParallelogramF
Type definition for parallelogram class for float.
Definition: fx_coordinates.h:341
int right
The right.
Definition: fx_coordinates.h:597
FX_FLOAT GetA() const
Get the coefficient a.
Definition: fx_coordinates.h:1553
CFX_ATemplate< FX_INT32 > CFX_Arc
Type definition for arc class for integer.
Definition: fx_coordinates.h:580
FX_BOOL operator!=(const FX_RECT &src) const
Compare(!=) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:697
void SetIdentity()
Set the matrix to be an identity transformation matrix.
Definition: fx_coordinates.h:1129
FX_RECT GetInnerRect() const
Convert to an inner integer rectangle.
void Inflate(FX_FLOAT x, FX_FLOAT y)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:964
void Transform(const CFX_Matrix *pMatrix)
Transform a rectangle. The result rectangle is always normalized.
CFX_PSVTemplate< FX_FLOAT > * FX_LPPOINTF
Type definition for pointer to float point.
Definition: fx_coordinates.h:222
void InitRect(FX_FLOAT x, FX_FLOAT y)
Initialize the rectangle to a single point.
Definition: fx_coordinates.h:930
CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
Construct a rectangle with left-bottom and right-top corners.
Definition: fx_coordinates.h:782
CFX_PSVTemplate< FX_INT32 > CFX_Point
Type definition for point class for integer.
Definition: fx_coordinates.h:208
CFX_FloatRect()
Construct an empty rectangle.
Definition: fx_coordinates.h:772
FX_SHORT Left
The left.
Definition: fx_coordinates.h:753
CFX_Matrix()
Construct a identity transformation matrix.
Definition: fx_coordinates.h:1062
FX_FLOAT startAngle
Start angle to draw arc. Positive is counterclockwise, in radian.
Definition: fx_coordinates.h:574
FXT_PSV & operator*=(BaseType lamda)
Overload operator *=.
Definition: fx_coordinates.h:128
baseType xRadius
x radius of round corner. This must not exceed the half width.
Definition: fx_coordinates.h:537
void ConcatInverse(const CFX_Matrix &m, FX_BOOL bPrepended=false)
Concatenate the inverse of another matrix.
void Offset(int dx, int dy)
Shift the coordinates by delta value of x and y directions.
Definition: fx_coordinates.h:708
FX_FLOAT Width() const
Get the width of the rectangle.
Definition: fx_coordinates.h:947
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:665
FX_BOOL IsInvertible() const
Determine whether a matrix is invertible or not.
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
void Union(const CFX_FloatRect &other_rect)
Union with a rect.
CFX_RTemplate< FX_INT32 > * FX_LPRECT
Type definition for pointer to integer rectangle.
Definition: fx_coordinates.h:455
FX_FLOAT GetXUnit() const
Get the x-direction unit size.
FX_SHORT Bottom
The bottom.
Definition: fx_coordinates.h:759
FX_FLOAT GetF() const
Get the coefficient f.
Definition: fx_coordinates.h:1588
void GetUnitParallelogram(CFX_ParallelogramF &pg) const
Get a parallelogram conposing two unit vectors.
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:673
FX_FLOAT GetYUnit() const
Get the y-direction unit size.
CFX_PSVTemplate< FX_FLOAT > const * FX_LPCPOINTF
Type definition for constant pointer to float point.
Definition: fx_coordinates.h:226
FXT_PSV & operator/=(BaseType lamda)
Overload operator /=.
Definition: fx_coordinates.h:136
FX_FLOAT c
The coefficient c.
Definition: fx_coordinates.h:1596
void TransformParallelogram(CFX_ParallelogramF &pg) const
Transform a parallelogram.
CFX_PSVTemplate< FX_INT32 > const * FX_LPCPOINT
Type definition for constant pointer to integer point.
Definition: fx_coordinates.h:224
FX_FLOAT a
The coefficient a.
Definition: fx_coordinates.h:1592
int Substract4(CFX_FloatRect &substract_rect, CFX_FloatRect *pRects)
Subtract a rectangle area from this rectangle. The result might be up to 4 rectangles....
FX_BOOL IsEmpty() const
Verify whether the rect is empty.
Definition: fx_coordinates.h:804
CFX_ATemplate< FX_FLOAT > CFX_ArcF
Type definition for arc class for float.
Definition: fx_coordinates.h:582
CFX_RTemplate< FX_FLOAT > const * FX_LPCRECTF
Type definition for constant pointer to float rectangle.
Definition: fx_coordinates.h:461
FX_BOOL IsEmpty() const
Verify whether the rect is empty.
Definition: fx_coordinates.h:641
void Add(BaseType x, BaseType y)
Add a point.
Definition: fx_coordinates.h:88
FX_FLOAT GetD() const
Get the coefficient d.
Definition: fx_coordinates.h:1574
FXT_PSV & operator-=(const FXT_PSV &obj)
Overload operator -=.
Definition: fx_coordinates.h:120
void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const
Transform points.
#define FXSYS_acos
Calculate the arccosine of a floating-point number, in radians.
Definition: fx_system.h:1422
void Reset()
Reset to the base point.
Definition: fx_coordinates.h:103
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:657
void Transform(FX_FLOAT &x, FX_FLOAT &y) const
Transform a point.
Definition: fx_coordinates.h:1438
#define FXSYS_fabs
Calculate the absolute. FXSYS_fabs(x) means |x|.
Definition: fx_system.h:1397
FX_FLOAT GetC() const
Get the coefficient c.
Definition: fx_coordinates.h:1567
#define FXSYS_cos
Calculate the cosine of a floating-point number from a radian argument.
Definition: fx_system.h:1417
void Deflate(FX_FLOAT x, FX_FLOAT y)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:994
int left
The left.
Definition: fx_coordinates.h:593
Definition: fx_basic.h:1287
CFX_PSVTemplate< FX_FLOAT > CFX_SizeF
Type definition for size class for float.
Definition: fx_coordinates.h:214
void SetReverse(const CFX_Matrix &m)
Set the coefficients of the inverse of another matrix to this matrix.
FX_FLOAT Height() const
Get the height of the rectangle.
Definition: fx_coordinates.h:954
FX_BOOL Is90Rotated() const
Whether this matrix has rotating of 90, or -90 degrees.
CFX_ETemplate< FX_INT32 > CFX_Ellipse
Type definition for ellipse class for integer.
Definition: fx_coordinates.h:516
CFX_FloatRect GetUnitRect() const
Get a bounding rectangle of the parallelogram composing two unit vectors.
void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended=false)
Translate the matrix.
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:667
void UpdateRect(FX_FLOAT x, FX_FLOAT y)
Update the rectangle to contain the specified point.
#define FXSYS_assert
Assertion.
Definition: fx_system.h:783
FXT_PSV & operator+=(const FXT_PSV &obj)
Overload operator +=.
Definition: fx_coordinates.h:112
FX_BOOL operator!=(const CFX_FloatRect &src) const
Compare(!=) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:831
CFX_PSVTemplate< FX_INT32 > * FX_LPPOINT
Type definition for pointer to integer point.
Definition: fx_coordinates.h:220
Definition: fx_coordinates.h:33
void Set(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f)
Change the coefficients in the matrix.
CFX_RTemplate< FX_INT32 > CFX_Rect
Type definition for rectangle class for integer.
Definition: fx_coordinates.h:451
Definition: fx_coordinates.h:590
FX_FLOAT GetUnitArea() const
Get area of the parallelogram composing two unit vectors.
void Inflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
Increases the width and height of the rectangle.
Definition: fx_coordinates.h:975
void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended=false)
Rotate the matrix at a position.
FX_BOOL Contains(int x, int y) const
Check if current rectangle contains the provided point. That means to check if the provided point is ...
Definition: fx_coordinates.h:733
friend FXT_PSV operator/(const FXT_PSV &obj, BaseType lamda)
Overload operator /.
Definition: fx_coordinates.h:200
void Deflate(FX_FLOAT left, FX_FLOAT bottom, FX_FLOAT right, FX_FLOAT top)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:1005
friend FX_BOOL operator==(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator ==.
Definition: fx_coordinates.h:146
FX_SHORT Top
The top.
Definition: fx_coordinates.h:755
CFX_RTemplate< FX_INT32 > const * FX_LPCRECT
Type definition for constant pointer to integer rectangle.
Definition: fx_coordinates.h:459
void Copy(const CFX_Matrix &m)
Copy coefficients from another matrix.
Definition: fx_coordinates.h:1186
CFX_VTemplate< FX_FLOAT > CFX_VectorF
Vector class for float.
Definition: fx_coordinates.h:298
FX_FLOAT GetB() const
Get the coefficient b.
Definition: fx_coordinates.h:1560
friend FXT_PSV operator+(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator +.
Definition: fx_coordinates.h:164
FX_FLOAT f
The coefficient f.
Definition: fx_coordinates.h:1602
FX_FLOAT right
The right.
Definition: fx_coordinates.h:1038
FX_BOOL operator!=(const CFX_Matrix &src) const
Compare(!=) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:1096
void Intersect(const CFX_FloatRect &other_rect)
Intersect with a rect.
void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src)
Get a matrix that transforms a source rectangle to dest rectangle.
FX_FLOAT TransformDistance(FX_FLOAT dx, FX_FLOAT dy) const
Transform distance specified by x and y value.
Definition: fx_coordinates.h:34
CFX_FloatRect(const FX_FLOAT *pArray)
Construct a rectangle with an array of left, bottom, right, top values.
Definition: fx_coordinates.h:789
CFX_PSVTemplate< FX_INT32 > CFX_Size
Type definition for size class for integer.
Definition: fx_coordinates.h:212
Definition: fx_coordinates.h:31
FX_FLOAT bottom
The bottom.
Definition: fx_coordinates.h:1040
void Intersect(const FX_RECT &src)
Intersect with a rect.
Definition: fx_coordinates.h:32
friend FX_BOOL operator!=(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator !=.
Definition: fx_coordinates.h:155
void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended=false)
Shear the matrix.
FX_BOOL Contains(const CFX_FloatRect &other_rect) const
Check if current rectangle fully contains the other provided rectangle. That means to check if the ot...
Definition: fx_coordinates.h:36
CFX_PSVTemplate< FX_FLOAT > CFX_PointF
Type definition for point class for float.
Definition: fx_coordinates.h:210
FX_FLOAT left
The left.
Definition: fx_coordinates.h:1036
CFX_ETemplate< FX_FLOAT > CFX_EllipseF
Type definition for ellipse class for float.
Definition: fx_coordinates.h:518
Definition: fx_coordinates.h:35
void Reset()
Reset rectangle, set coordinates to 0.
Definition: fx_coordinates.h:840
friend FXT_PSV operator-(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator -.
Definition: fx_coordinates.h:173
friend FXT_PSV operator*(const FXT_PSV &obj, BaseType lamda)
Overload operator *.
Definition: fx_coordinates.h:182
void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended=false)
Rotate the matrix.
BaseType y
y coordinate of the point.
Definition: fx_coordinates.h:205
FX_FLOAT TransformXDistance(FX_FLOAT dx) const
Transform a x-distance.
Definition: fx_coordinates.h:1056
void Set(const FXT_PSV &psv)
Set values.
Definition: fx_coordinates.h:79
#define FXSYS_sqrt
Calculate the square root. FXSYS_sqrt(x) means sqrt(x).
Definition: fx_system.h:1392
FX_BOOL operator==(const CFX_FloatRect &src) const
Compare(==) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:820
FX_BOOL operator==(const CFX_Matrix &src) const
Compare(==) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:1084
void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended=false)
Scale the matrix.
FX_FLOAT top
The top.
Definition: fx_coordinates.h:1042
FX_RECT()
Construct a rect not initialized.
Definition: fx_coordinates.h:604
FX_FLOAT GetE() const
Get the coefficient e.
Definition: fx_coordinates.h:1581
CFX_RRTemplate< FX_INT32 > CFX_RoundRect
Type definition for round-corner rectangle class for integer.
Definition: fx_coordinates.h:543
void Translate(FX_FLOAT e, FX_FLOAT f)
Translate rectangle.
Definition: fx_coordinates.h:1023
CFX_RTemplate< FX_FLOAT > CFX_RectF
Type definition for rectangle class for float.
Definition: fx_coordinates.h:453
baseType yRadius
y radius of round corner. This must not exceed the half height.
Definition: fx_coordinates.h:539
void TransformRoundRect(CFX_RoundRectF &rr) const
Transform a round rectangle.
void Deflate(const CFX_FloatRect &rt)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:1013
CFX_Matrix(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1, FX_FLOAT d1, FX_FLOAT e1, FX_FLOAT f1)
Construct a matrix with six input coefficients.
Definition: fx_coordinates.h:1074
CFX_PSVTemplate(const CFX_PSVTemplate &other)
Copy constructor.
Definition: fx_coordinates.h:61
Definition: fx_coordinates.h:766
FX_SHORT Right
The right.
Definition: fx_coordinates.h:757
FX_FLOAT d
The coefficient d.
Definition: fx_coordinates.h:1598
FX_BOOL IsIdentity() const
Determine whether a matrix is an identity transformation or not.
Definition: fx_coordinates.h:1193
FX_BOOL operator==(const FX_RECT &src) const
Compare(==) operator overload. Compare two rectangles. Please make sure they are normalized first.
Definition: fx_coordinates.h:687
Definition: fx_coordinates.h:750
FX_FLOAT e
The coefficient e.
Definition: fx_coordinates.h:1600
void Subtract(BaseType x, BaseType y)
Subtract a point.
Definition: fx_coordinates.h:97
CFX_VTemplate< FX_INT32 > CFX_Vector
Vector class for integer.
Definition: fx_coordinates.h:296