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) {}
53 
60  CFX_PSVTemplate(BaseType new_x, BaseType new_y) : x(new_x), y(new_y) {}
61 
67  CFX_PSVTemplate(const CFX_PSVTemplate& other) : x(other.x), y(other.y) {}
68 
77  void Set(BaseType x, BaseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
85  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
94  void Add(BaseType x, BaseType y) {FXT_PSV::x += x, FXT_PSV::y += y;}
103  void Subtract(BaseType x, BaseType y) {FXT_PSV::x -= x, FXT_PSV::y -= y;}
109  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
110 
118  FXT_PSV& operator += (const FXT_PSV &obj) {x += obj.x; y += obj.y; return *this;}
126  FXT_PSV& operator -= (const FXT_PSV &obj) {x -= obj.x; y -= obj.y; return *this;}
134  FXT_PSV& operator *= (BaseType lamda) {x *= lamda; y *= lamda; return *this;}
142  FXT_PSV& operator /= (BaseType lamda) {x /= lamda; y /= lamda; return *this;}
143 
152  friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x == obj2.x && obj1.y == obj2.y;}
161  friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) {return obj1.x != obj2.x || obj1.y != obj2.y;}
170  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;}
179  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;}
188  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;}
197  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;}
206  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;}
207 
209  BaseType x;
211  BaseType y;
212 };
233 
234 //Keep old symbol
235 #define CFX_FloatPoint CFX_PointF
236 
238 template<class baseType>
239 class CFX_VTemplate: public CFX_PSVTemplate<baseType>
240 {
241  public:
242  typedef CFX_PSVTemplate<baseType> FXT_PSV;
243  typedef CFX_PSVTemplate<baseType> FXT_POINT;
244  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
245  typedef CFX_VTemplate<baseType> FXT_VECTOR;
246 
247  void Set(baseType x, baseType y) {FXT_PSV::x = x, FXT_PSV::y = y;}
248  void Set(const FXT_PSV &psv) {FXT_PSV::x = psv.x, FXT_PSV::y = psv.y;}
249  void Set(const FXT_POINT &p1, const FXT_POINT &p2) {FXT_PSV::x = p2.x - p1.x, FXT_PSV::y = p2.y - p1.y;}
250  void Reset() {FXT_PSV::x = FXT_PSV::y = 0;}
251 
252  baseType SquareLength() const {return FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y;}
253  baseType Length() const {return FXSYS_sqrt(FXT_PSV::x * FXT_PSV::x + FXT_PSV::y * FXT_PSV::y);}
254  void Normalize()
255  {
257  FXSYS_assert(fLen >= 0.0001f);
258  if (fLen < 0.0001f)
259  return;
260  FXT_PSV::x = ((baseType)FXT_PSV::x) / fLen;
261  FXT_PSV::y = ((baseType)FXT_PSV::y) / fLen;
262  }
263  baseType DotProduct(baseType x, baseType y) const {return FXT_PSV::x * x + FXT_PSV::y * y;}
264  baseType DotProduct(const FXT_VECTOR &v) const {return FXT_PSV::x * v.x + FXT_PSV::y * v.y;}
265  FX_BOOL IsParallel(baseType x, baseType y) const {baseType t = FXT_PSV::x * y - FXT_PSV::y * x; return FXSYS_fabs(t) < 0.0001f;}
266  FX_BOOL IsParallel(const FXT_VECTOR &v) const {return IsParallel(v.x, v.y);}
267  FX_BOOL IsPerpendicular(baseType x, baseType y) const {baseType t = DotProduct(x, y); return FXSYS_fabs(t) < 0.0001f;}
268  FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const {return IsPerpendicular(v.x, v.y);}
269 
270  void Translate(baseType dx, baseType dy) {FXT_PSV::x += dx, FXT_PSV::y += dy;}
271  void Scale(baseType sx, baseType sy) {FXT_PSV::x *= sx, FXT_PSV::y *= sy;}
272  void Rotate(FX_FLOAT fRadian)
273  {
276  FX_FLOAT cosValue = FXSYS_cos(fRadian);
277  FX_FLOAT sinValue = FXSYS_sin(fRadian);
278  FXT_PSV::x = xx * cosValue - yy * sinValue;
279  FXT_PSV::y = xx * sinValue + yy * cosValue;
280  }
281 
282  friend FX_FLOAT Cosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
283  {
284  FXSYS_assert(v1.SquareLength() != 0 && v2.SquareLength() != 0);
285  FX_FLOAT dotProduct = v1.DotProduct(v2);
286  return dotProduct / (FX_FLOAT)FXSYS_sqrt(v1.SquareLength() * v2.SquareLength());
287  }
288  friend FX_FLOAT ArcCosine(const FXT_VECTOR &v1, const FXT_VECTOR &v2)
289  {
290  return (FX_FLOAT)FXSYS_acos(Cosine(v1, v2));
291  }
292  friend FX_FLOAT SlopeAngle(const FXT_VECTOR &v)
293  {
294  CFX_VTemplate vx;
295  vx.Set(1, 0);
296  FX_FLOAT fSlope = ArcCosine(v, vx);
297  return v.y < 0 ? -fSlope : fSlope;
298  }
299 };
300 
305 
307 template<class baseType>
308 class CFX_PRLTemplate: public CFX_Object
309 {
310  public:
311  typedef CFX_PSVTemplate<baseType> FXT_POINT;
312  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
313  typedef CFX_VTemplate<baseType> FXT_VECTOR;
314  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
315 
316  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;}
317  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);}
318  void Reset() {FXT_PARAL::x = FXT_PARAL::y = FXT_PARAL::x1 = FXT_PARAL::y1 = FXT_PARAL::x2 = FXT_PARAL::y2 = 0;}
319 
320  CFX_PRLTemplate& operator += (const FXT_POINT &p) {x += p.x; y += p.y; return *this;}
321  CFX_PRLTemplate& operator -= (const FXT_POINT &p) {x -= p.x; y -= p.y; return *this;}
322 
323  FXT_POINT P() const {FXT_POINT p; p.x = x, p.y = y; return p;}
324  void P(FXT_POINT p) {x = p.x, y = p.y;}
325  FXT_VECTOR V1() const {FXT_VECTOR v; v.x = x1, v.y = y1; return v;}
326  void V1(FXT_VECTOR v) {x1 = v.x, y1 = v.y;}
327  FXT_VECTOR V2() const {FXT_VECTOR v; v.x = x2, v.y = y2; return v;}
328  void V2(FXT_VECTOR v) {x2 = v.x, y2 = v.y;}
329 
330  FX_BOOL IsEmpty() const {return V1().IsParallel(x2, y2);}
331  FX_BOOL IsRect() const {return V1().IsPerpendicular(x2, y2);}
332  FXT_SIZE Size() const {FXT_SIZE s; s.x = V1().Length(); s.y = V2().Length(); return s;}
333  FXT_POINT Center() const {return (V1() + V2()) / 2 + P();}
334  FXT_POINT P1() const {return P();}
335  FXT_POINT P2() const {return P() + V1();}
336  FXT_POINT P3() const {return P() + V1() + V2();}
337  FXT_POINT P4() const {return P() + V2();}
338 
339  baseType x, y;
340  baseType x1, y1;
341  baseType x2, y2;
342 };
343 
348 //<<<+++OPENSOURCE_MUST_END
349 
351 template<class baseType>
352 class CFX_RTemplate: public CFX_Object
353 {
354  public:
355  typedef CFX_PSVTemplate<baseType> FXT_POINT;
356  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
357  typedef CFX_VTemplate<baseType> FXT_VECTOR;
358  typedef CFX_PRLTemplate<baseType> FXT_PARAL;
359  typedef CFX_RTemplate<baseType> FXT_RECT;
360 
361  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;}
362  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
363  void Set(const FXT_POINT &p, baseType width, baseType height) {TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
364  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();}
365  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();}
366  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
367 
368  FXT_RECT& operator += (const FXT_POINT &p) {left += p.x, top += p.y; return *this;}
369  FXT_RECT& operator -= (const FXT_POINT &p) {left -= p.x, top -= p.y; return *this;}
370 
371  baseType right() const {return left + width;}
372  baseType bottom() const {return top + height;}
373  void Normalize() {if (width < 0) {left += width; width = -width;} if (height < 0) {top += height; height = -height;}}
374  void Offset(baseType dx, baseType dy) {left += dx; top += dy;}
375  void Inflate(baseType x, baseType y) {left -= x; width += x * 2; top -= y; height += y * 2;}
376  void Inflate(const FXT_POINT &p) {Inflate(p.x, p.y);}
377  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;}
378  void Inflate(const FXT_RECT &rt) {Inflate(rt.left, rt.top, rt.left + rt.width, rt.top + rt.height);}
379  void Deflate(baseType x, baseType y) {left += x; width -= x * 2; top += y; height -= y * 2;}
380  void Deflate(const FXT_POINT &p) {Deflate(p.x, p.y);}
381  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;}
382  void Deflate(const FXT_RECT &rt) {Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height);}
383  FX_BOOL IsEmpty() const {return width <= 0 || height <= 0;}
384  FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const {return width <= fEpsilon || height <= fEpsilon;}
385  void Empty() {width = height = 0;}
386  FX_BOOL Contains(baseType x, baseType y) const {return x >= left && x < left + width && y >= top && y < top + height;}
387  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
388  FX_BOOL Contains(const FXT_RECT &rt) const {return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom();}
389  baseType Width() const {return width;}
390  baseType Height() const {return height;}
391  FXT_SIZE Size() const {FXT_SIZE size; size.Set(width, height); return size;}
392  void Size(FXT_SIZE s) {width = s.x, height = s.y;}
393  FXT_POINT TopLeft() const {FXT_POINT p; p.x = left; p.y = top; return p;}
394  FXT_POINT TopRight() const {FXT_POINT p; p.x = left + width; p.y = top; return p;}
395  FXT_POINT BottomLeft() const {FXT_POINT p; p.x = left; p.y = top + height; return p;}
396  FXT_POINT BottomRight() const {FXT_POINT p; p.x = left + width; p.y = top + height; return p;}
397  void TopLeft(FXT_POINT tl) {left = tl.x; top = tl.y;}
398  void TopRight(FXT_POINT tr) {width = tr.x - left; top = tr.y;}
399  void BottomLeft(FXT_POINT bl) {left = bl.x; height = bl.y - top;}
400  void BottomRight(FXT_POINT br) {width = br.x - left; height = br.y - top;}
401  FXT_POINT Center() const {FXT_POINT p; p.x = left + width / 2; p.y = top + height / 2; return p;}
402 
403  void GetParallelogram(FXT_PARAL &pg) const {pg.x = left, pg.y = top; pg.x1 = width, pg.y1 = 0; pg.x2 = 0, pg.y2 = height;}
404 
405  void Union(baseType x, baseType y)
406  {
407  baseType r = right(), b = bottom();
408  if (left > x) left = x;
409  if (r < x) r = x;
410  if (top > y) top = y;
411  if (b < y) b = y;
412  width = r - left;
413  height = b - top;
414  }
415  void Union(const FXT_POINT &p) {Union(p.x, p.y);}
416  void Union(const FXT_RECT &rt)
417  {
418  baseType r = right(), b = bottom();
419  if (left > rt.left) left = rt.left;
420  if (r < rt.right()) r = rt.right();
421  if (top > rt.top) top = rt.top;
422  if (b < rt.bottom()) b = rt.bottom();
423  width = r - left;
424  height = b - top;
425  }
426  void Intersect(const FXT_RECT &rt)
427  {
428  baseType r = right(), b = bottom();
429  if (left < rt.left) left = rt.left;
430  if (r > rt.right()) r = rt.right();
431  if (top < rt.top) top = rt.top;
432  if (b > rt.bottom()) b = rt.bottom();
433  width = r - left;
434  height = b - top;
435  }
436  FX_BOOL IntersectWith(const FXT_RECT &rt) const
437  {
438  FXT_RECT rect = rt;
439  rect.Intersect(*this);
440  return !rect.IsEmpty();
441  }
442  FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const
443  {
444  FXT_RECT rect = rt;
445  rect.Intersect(*this);
446  return !rect.IsEmpty(fEpsilon);
447  }
448 
449  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;}
450  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;}
451 
452  baseType left, top;
453  baseType width, height;
454 };
455 
470 
472 template<class baseType>
473 class CFX_ETemplate : public CFX_RTemplate<baseType>
474 {
475  public:
476  typedef CFX_PSVTemplate<baseType> FXT_POINT;
477  typedef CFX_PSVTemplate<baseType> FXT_SIZE;
478  typedef CFX_VTemplate<baseType> FXT_VECTOR;
479  typedef CFX_RTemplate<baseType> FXT_RECT;
480 
481  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;}
482  void Set(baseType left, baseType top, const FXT_SIZE &size) {FXT_RECT::left = left, FXT_RECT::top = top, FXT_RECT::Size(size);}
483  void Set(const FXT_POINT &p, baseType width, baseType height) {FXT_RECT::TopLeft(p), FXT_RECT::width = width, FXT_RECT::height = height;}
484  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();}
485  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();}
486  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;}
487  void Reset() {FXT_RECT::left = FXT_RECT::top = FXT_RECT::width = FXT_RECT::height = 0;}
488 
489  FX_BOOL Contains(baseType x, baseType y) const
490  {
491  x -= FXT_RECT::left + FXT_RECT::width / 2;
492  y -= FXT_RECT::top + FXT_RECT::height / 2;
493  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;
494  }
495  FX_BOOL Contains(const FXT_POINT &p) const {return Contains(p.x, p.y);}
496  FX_BOOL Contains(const FXT_RECT &rt) const {return Contains(rt.TopLeft()) && Contains(rt.BottomRight());}
497 
498  baseType XRadius() const {return FXT_RECT::width / 2;}
499  baseType YRadius() const {return FXT_RECT::height / 2;}
500 
501  void GetPointF(FX_FLOAT fRadian, CFX_PointF &point) const
502  {
503  FX_FLOAT a = (FX_FLOAT)FXT_RECT::width / 2.0f;
504  FX_FLOAT b = (FX_FLOAT)FXT_RECT::height / 2.0f;
505  FX_FLOAT sinValue = (FX_FLOAT)FXSYS_sin(fRadian);
506  FX_FLOAT cosValue = (FX_FLOAT)FXSYS_cos(fRadian);
507  FX_FLOAT d = FXSYS_sqrt(b * b * cosValue * cosValue + a * a * sinValue * sinValue);
508  fRadian = a * b;
509  point.x = fRadian * cosValue / d + FXT_RECT::left + a;
510  point.y = fRadian * sinValue / d + FXT_RECT::top + b;
511  }
512  void GetPoint(FX_FLOAT fRadian, CFX_Point &point) const
513  {
514  CFX_PointF p;
515  GetPointF(fRadian, p);
516  point.x = FXSYS_round(p.x + 0.5f);
517  point.y = FXSYS_round(p.y + 0.5f);
518  }
519 };
520 
525 
527 template<class baseType>
528 class CFX_RRTemplate: public CFX_RTemplate<baseType>
529 {
530  public:
531  typedef CFX_PSVTemplate<baseType> FXT_POINT;
532  typedef CFX_VTemplate<baseType> FXT_VECTOR;
533  typedef CFX_RTemplate<baseType> FXT_RECT;
534  typedef CFX_RRTemplate<baseType> FXT_RRECT;
535 
536  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;}
537  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();}
538  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();}
539  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;}
540  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_RRECT));}
541 
543  baseType xRadius;
545  baseType yRadius;
546 };
547 
552 
554 template<class baseType>
555 class CFX_ATemplate: public CFX_ETemplate<baseType>
556 {
557  public:
558  typedef CFX_PSVTemplate<baseType> FXT_POINT;
559  typedef CFX_VTemplate<baseType> FXT_VECTOR;
560  typedef CFX_RTemplate<baseType> FXT_RECT;
561  typedef CFX_ETemplate<baseType> FXT_ELLIPSE;
562  typedef CFX_ATemplate<baseType> FXT_ARC;
563 
564  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;}
565  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();}
566  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();}
567  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;}
568  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;}
569  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;}
570  void Reset() {FXSYS_memset32((void*)this, 0, sizeof(FXT_ARC));}
571 
572  FX_FLOAT EndAngle() const {return startAngle + sweepAngle;}
573  void EndAngle(FX_FLOAT endAngle) {sweepAngle = endAngle - startAngle;}
574  void StartPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(startAngle, point);}
575  void EndPointF(CFX_PointF &point) const {FXT_ELLIPSE::GetPointF(EndAngle(), point);}
576  void StartPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(startAngle, point);}
577  void EndPoint(CFX_Point &point) const {FXT_ELLIPSE::GetPoint(EndAngle(), point);}
578 
583 };
584 
589 //<<<+++OPENSOURCE_END
590 
596 struct FX_RECT
597 {
599  int left;
601  int top;
603  int right;
605  int bottom;
606 
611  left = 0;
612  top = 0;
613  right = 0;
614  bottom = 0;
615  }
616 
625  FX_RECT(int left1, int top1, int right1, int bottom1)
626  { left = left1; top = top1; right = right1; bottom = bottom1; }
627 
633  int Width() const { return right - left; }
634 
640  int Height() const { return bottom - top; }
641 
647  FX_BOOL IsEmpty() const { return right <= left || bottom <= top; }
648 
654  void Normalize();
655 
663  void Intersect(const FX_RECT& src);
664 
675  void Intersect(int left1, int top1, int right1, int bottom1) { Intersect(FX_RECT(left1, top1, right1, bottom1)); }
676 
684  void Union(const FX_RECT& other_rect);
685 
693  FX_BOOL operator == (const FX_RECT& src) const
694  { return left == src.left && right == src.right && top == src.top && bottom == src.bottom; }
695 
703  FX_BOOL operator != (const FX_RECT& src) const
704  { return left != src.left || right != src.right || top != src.top || bottom != src.bottom; }
705 
714  void Offset(int dx, int dy) { left += dx; right += dx; top += dy; bottom += dy; }
715 
724  FX_BOOL Contains(const FX_RECT& other_rect) const
725  {
726  // Assume both rects are normalized!
727  return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom;
728  }
729 
739  FX_BOOL Contains(int x, int y) const
740  {
741  // Assume the rectangle is normalized!
742  return x >= left && x < right && y >= top && y < bottom;
743  }
749  FX_BOOL Valid() const;
750 };
751 
756 {
765 };
766 
771 class CFX_FloatRect : public CFX_Object
772 {
773  public:
777  CFX_FloatRect() { left = right = bottom = top = 0; }
778 
787  CFX_FloatRect(FX_FLOAT left1, FX_FLOAT bottom1, FX_FLOAT right1, FX_FLOAT top1)
788  { left = left1; bottom = bottom1; right = right1; top = top1; }
794  CFX_FloatRect(const FX_FLOAT* pArray)
795  { left = pArray[0]; bottom = pArray[1]; right = pArray[2]; top = pArray[3]; }
801  CFX_FloatRect(const FX_RECT& rect);
802 
808  FX_BOOL IsEmpty() const { return left >= right || bottom >= top; }
809 
815  void Normalize();
816 
825  { return FXSYS_fabs(left - src.left) < FLT_EPSILON && FXSYS_fabs(right - src.right) < FLT_EPSILON &&
826  FXSYS_fabs(top - src.top) < FLT_EPSILON && FXSYS_fabs(bottom - src.bottom) < FLT_EPSILON; }
827 
836  { return FXSYS_fabs(left - src.left) > FLT_EPSILON || FXSYS_fabs(right - src.right) > FLT_EPSILON ||
837  FXSYS_fabs(top - src.top) > FLT_EPSILON || FXSYS_fabs(bottom - src.bottom) > FLT_EPSILON; }
838 
844  void Reset() {left = right = bottom = top = 0;}
845 
854  FX_BOOL Contains(const CFX_FloatRect& other_rect) const;
855 
865  FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const;
866 
874  void Transform(const CFX_Matrix* pMatrix);
875 
883  void Intersect(const CFX_FloatRect& other_rect);
884 
892  void Union(const CFX_FloatRect& other_rect);
893 
899  FX_RECT GetInnerRect() const;
900 
906  FX_RECT GetOutterRect() const;
907 
913  FX_RECT GetClosestRect() const;
923  int Substract4(CFX_FloatRect& substract_rect, CFX_FloatRect* pRects);
932  void InitRect(FX_FLOAT x, FX_FLOAT y) { left = right = x; bottom = top = y; }
933 
942  void UpdateRect(FX_FLOAT x, FX_FLOAT y);
943 
949  FX_FLOAT Width() const { return right - left; }
950 
956  FX_FLOAT Height() const { return top - bottom; }
957 
966  void Inflate(FX_FLOAT x, FX_FLOAT y) { Inflate(x, y, x, y); }
977  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;}
978 
986  void Inflate(const CFX_FloatRect &rt) {Inflate(rt.left, rt.bottom, rt.right, rt.top);}
987 
996  void Deflate(FX_FLOAT x, FX_FLOAT y) { Deflate(x, y, x, y); }
1015  void Deflate(const CFX_FloatRect &rt) {Deflate(rt.left, rt.bottom, rt.right, rt.top);}
1016 
1025  void Translate(FX_FLOAT e, FX_FLOAT f) {left += e; right += e; top += f; bottom += f;}
1026 
1035  static CFX_FloatRect GetBBox(const CFX_FloatPoint* pPoints, int nPoints);
1036 
1045 };
1046 
1063 FX_BOOL FX_IsRectAdjacent(const CFX_FloatRect& rect1, const CFX_FloatRect& rect2, FX_FLOAT alignmentTolerance, FX_FLOAT distanceTolerance, int direction);
1064 
1067 
1076 class CFX_Matrix : public CFX_Object
1077 {
1078  public:
1082  CFX_Matrix() {a = d = 1; b = c = e = f = 0;}
1083 
1095  {a = a1; b = b1; c = c1; d = d1; e = e1; f = f1;}
1096 
1104  FX_BOOL operator == (const CFX_Matrix& src) const
1105  { return FXSYS_fabs(a - src.a) < FLT_EPSILON && FXSYS_fabs(b - src.b) < FLT_EPSILON &&
1106  FXSYS_fabs(c - src.c) < FLT_EPSILON && FXSYS_fabs(d - src.d) < FLT_EPSILON &&
1107  FXSYS_fabs(e - src.e) < FLT_EPSILON && FXSYS_fabs(f - src.f) < FLT_EPSILON; }
1108 
1116  FX_BOOL operator != (const CFX_Matrix& src) const
1117  { return FXSYS_fabs(a - src.a) > FLT_EPSILON || FXSYS_fabs(b - src.b) > FLT_EPSILON ||
1118  FXSYS_fabs(c - src.c) > FLT_EPSILON || FXSYS_fabs(d - src.d) > FLT_EPSILON ||
1119  FXSYS_fabs(e - src.e) > FLT_EPSILON || FXSYS_fabs(f - src.f) > FLT_EPSILON; }
1120 
1134 
1142  void Set(const FX_FLOAT n[6]);
1143 
1149  void SetIdentity() {a = d = 1; b = c = e = f = 0;}
1150 
1158  void SetReverse(const CFX_Matrix &m);
1159 
1173  void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = false);
1182  void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = false);
1191  void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = false);
1197  void Reset() {SetIdentity();}
1198 
1206  void Copy(const CFX_Matrix& m) {*this = m;}
1207 
1213  FX_BOOL IsIdentity() const {return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0;}
1214 
1220  FX_BOOL IsInvertible() const;
1221 
1227  FX_BOOL Is90Rotated() const;
1228 
1234  FX_BOOL IsScaled() const;
1235 
1245  void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = false);
1255  void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended = false) {Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended);}
1265  void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = false);
1274  void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = false);
1285  void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = false);
1295  void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = false);
1296 
1305  void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src);
1306 
1312  FX_FLOAT GetXUnit() const;
1313 
1319  FX_FLOAT GetYUnit() const;
1320 
1328  void GetUnitParallelogram(CFX_ParallelogramF &pg) const;
1336  void GetUnitRect(CFX_RectF &rect) const;
1342  CFX_FloatRect GetUnitRect() const;
1348  FX_FLOAT GetUnitArea() const;
1349 
1350 #ifdef _FXGE_IMAGERENDER_SHORTCUT_
1351  const FX_INT32 GetRotation() const;
1352  const FX_BOOL NeedTransform() const;
1353 #endif
1354 
1412  FX_FLOAT TransformDistance(FX_FLOAT distance) const;
1413 
1422  void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const;
1431  void TransformPoint(FX_INT32 &x, FX_INT32 &y) const;
1440  void TransformPoints(CFX_PointF *points, FX_INT32 iCount) const;
1441 
1450  void TransformPoints(CFX_Point *points, FX_INT32 iCount) const;
1451 
1460  void Transform(FX_FLOAT& x, FX_FLOAT& y) const {TransformPoint(x, y);}
1461 
1472  void Transform(FX_FLOAT x, FX_FLOAT y, FX_FLOAT& x1, FX_FLOAT& y1) const {x1 = x, y1 = y; TransformPoint(x1, y1);}
1473 
1481  void TransformVector(CFX_VectorF &v) const;
1482 
1490  void TransformVector(CFX_Vector &v) const;
1491 
1500 
1508  void TransformParallelogram(CFX_Parallelogram &pg) const;
1509 
1518  void TransformRect(CFX_RectF &rect) const;
1519 
1528  void TransformRect(CFX_Rect &rect) const;
1529 
1541  void TransformRect(FX_FLOAT& left, FX_FLOAT& right, FX_FLOAT& top, FX_FLOAT& bottom) const;
1542 
1551  void TransformRect(CFX_FloatRect& rect) const {TransformRect(rect.left, rect.right, rect.top, rect.bottom);}
1560  void TransformRect(FX_RECT& rect) const;
1561 
1569  void TransformRoundRect(CFX_RoundRectF &rr) const;
1570 
1578  void TransformRoundRect(CFX_RoundRect &rr) const;
1579 
1585  FX_FLOAT GetA() const {return a;}
1586 
1592  FX_FLOAT GetB() const {return b;}
1593 
1599  FX_FLOAT GetC() const {return c;}
1600 
1606  FX_FLOAT GetD() const {return d;}
1607 
1613  FX_FLOAT GetE() const {return e;}
1614 
1620  FX_FLOAT GetF() const {return f;}
1621 
1622  public:
1635 };
1636 
1637 class CFX_Vector_3by1 : public CFX_Object
1638 {
1639  public:
1640 CFX_Vector_3by1():
1641  a(0.0f),
1642  b(0.0f),
1643  c(0.0f)
1644  {}
1645  CFX_Vector_3by1(FX_FLOAT a1, FX_FLOAT b1, FX_FLOAT c1):
1646  a(a1),
1647  b(b1),
1648  c(c1)
1649  {}
1650  FX_FLOAT a;
1651  FX_FLOAT b;
1652  FX_FLOAT c;
1653 };
1654 
1655 class CFX_Matrix_3by3 : public CFX_Object
1656 {
1657  public:
1658 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)
1659  {}
1660 
1661  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) :
1662  a(a1), b(b1), c(c1), d(d1), e(e1), f(f1), g(g1), h(h1), i(i1)
1663  {}
1664  CFX_Matrix_3by3 Inverse();
1665  CFX_Matrix_3by3 Multiply(const CFX_Matrix_3by3 &m);
1666  CFX_Vector_3by1 TransformVector(const CFX_Vector_3by1 &v) const;
1667  FX_FLOAT a;
1668  FX_FLOAT b;
1669  FX_FLOAT c;
1670  FX_FLOAT d;
1671  FX_FLOAT e;
1672  FX_FLOAT f;
1673  FX_FLOAT g;
1674  FX_FLOAT h;
1675  FX_FLOAT i;
1676 };
1677 
1678 //Keep old symbol
1679 #define CFX_AffineMatrix CFX_Matrix
1680 
1681 //<<<+++OPENSOURCE_MUST_BEGIN
1682 #endif //_FXCRT_COORDINATES_
1683 //<<<+++OPENSOURCE_MUST_END
1684 
1687 //<<<+++OPENSOURCE_END
CFX_PSVTemplate(BaseType new_x, BaseType new_y)
Constructor, with parameters.
Definition: fx_coordinates.h:60
int top
The top.
Definition: fx_coordinates.h:601
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:345
CFX_PSVTemplate()
Constructor.
Definition: fx_coordinates.h:52
void Set(BaseType x, BaseType y)
Set values.
Definition: fx_coordinates.h:77
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:605
void Normalize()
Normalize the rect. Make sure left <= right, top <= bottom.
int Width() const
Get the width of the rect.
Definition: fx_coordinates.h:633
void Intersect(int left1, int top1, int right1, int bottom1)
Intersect with a rect.
Definition: fx_coordinates.h:675
CFX_ArrayTemplate< CFX_FloatRect > CFX_RectArray
Rectangle array.
Definition: fx_coordinates.h:1066
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:1551
FXT_PSV & operator *=(BaseType lamda)
Overload operator *=.
Definition: fx_coordinates.h:134
void TransformPoint(FX_FLOAT &x, FX_FLOAT &y) const
Transform point specified by x and y value.
void TranslateI(FX_INT32 x, FX_INT32 y, FX_BOOL bPrepended=false)
Translate the matrix. using integer value.
Definition: fx_coordinates.h:1255
int Height() const
Get the height of the rect.
Definition: fx_coordinates.h:640
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:1472
FX_RECT GetClosestRect() const
Get a closest integer rectangle.
BaseType x
x coordinate of the point.
Definition: fx_coordinates.h:209
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:835
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:724
CFX_ArrayTemplate< CFX_RectF > CFX_RectFArray
Type definition for rect array.
Definition: fx_coordinates.h:469
FX_RECT(int left1, int top1, int right1, int bottom1)
Construct a rect with left-top and right bottom corners.
Definition: fx_coordinates.h:625
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:463
CFX_ArrayTemplate< CFX_PointF > CFX_PointsF
Type definition for float point array.
Definition: fx_coordinates.h:224
FX_FLOAT b
The coefficient b.
Definition: fx_coordinates.h:1626
void Reset()
Reset current matrix.
Definition: fx_coordinates.h:1197
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:551
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:222
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:986
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:582
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:1410
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:347
FXT_PSV & operator -=(const FXT_PSV &obj)
Overload operator -=.
Definition: fx_coordinates.h:126
int right
The right.
Definition: fx_coordinates.h:603
FX_FLOAT GetA() const
Get the coefficient a.
Definition: fx_coordinates.h:1585
CFX_ATemplate< FX_INT32 > CFX_Arc
Type definition for arc class for integer.
Definition: fx_coordinates.h:586
void SetIdentity()
Set the matrix to be an identity transformation matrix.
Definition: fx_coordinates.h:1149
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:966
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:228
void InitRect(FX_FLOAT x, FX_FLOAT y)
Initialize the rectangle to a single point.
Definition: fx_coordinates.h:932
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:787
CFX_PSVTemplate< FX_INT32 > CFX_Point
Type definition for point class for integer.
Definition: fx_coordinates.h:214
CFX_FloatRect()
Construct an empty rectangle.
Definition: fx_coordinates.h:777
FX_SHORT Left
The left.
Definition: fx_coordinates.h:758
CFX_Matrix()
Construct a identity transformation matrix.
Definition: fx_coordinates.h:1082
FX_BOOL FX_IsRectAdjacent(const CFX_FloatRect &rect1, const CFX_FloatRect &rect2, FX_FLOAT alignmentTolerance, FX_FLOAT distanceTolerance, int direction)
Check if a rectangle is adjacent to the other rectangle in the horizontal or vertical direction.
FX_FLOAT startAngle
Start angle to draw arc. Positive is counterclockwise, in radian.
Definition: fx_coordinates.h:580
baseType xRadius
x radius of round corner. This must not exceed the half width.
Definition: fx_coordinates.h:543
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:714
FX_FLOAT Width() const
Get the width of the rectangle.
Definition: fx_coordinates.h:949
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:661
friend FXT_PSV operator -(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator -.
Definition: fx_coordinates.h:179
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:461
FX_FLOAT GetXUnit() const
Get the x-direction unit size.
FX_SHORT Bottom
The bottom.
Definition: fx_coordinates.h:764
FX_FLOAT GetF() const
Get the coefficient f.
Definition: fx_coordinates.h:1620
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:669
FX_FLOAT GetYUnit() const
Get the y-direction unit size.
FX_BOOL operator !=(const CFX_Matrix &src) const
Compare(!=) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:1116
CFX_PSVTemplate< FX_FLOAT > const * FX_LPCPOINTF
Type definition for constant pointer to float point.
Definition: fx_coordinates.h:232
FXT_PSV & operator/=(BaseType lamda)
Overload operator /=.
Definition: fx_coordinates.h:142
FX_FLOAT c
The coefficient c.
Definition: fx_coordinates.h:1628
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:230
FX_FLOAT a
The coefficient a.
Definition: fx_coordinates.h:1624
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:808
CFX_ATemplate< FX_FLOAT > CFX_ArcF
Type definition for arc class for float.
Definition: fx_coordinates.h:588
CFX_RTemplate< FX_FLOAT > const * FX_LPCRECTF
Type definition for constant pointer to float rectangle.
Definition: fx_coordinates.h:467
FX_BOOL IsEmpty() const
Verify whether the rect is empty.
Definition: fx_coordinates.h:647
void Add(BaseType x, BaseType y)
Add a point.
Definition: fx_coordinates.h:94
FX_FLOAT GetD() const
Get the coefficient d.
Definition: fx_coordinates.h:1606
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:1405
void Reset()
Reset to the base point.
Definition: fx_coordinates.h:109
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:653
void Transform(FX_FLOAT &x, FX_FLOAT &y) const
Transform a point.
Definition: fx_coordinates.h:1460
#define FXSYS_fabs
Calculate the absolute. FXSYS_fabs(x) means |x|.
Definition: fx_system.h:1380
FX_FLOAT GetC() const
Get the coefficient c.
Definition: fx_coordinates.h:1599
#define FXSYS_cos
Calculate the cosine of a floating-point number from a radian argument.
Definition: fx_system.h:1400
void Deflate(FX_FLOAT x, FX_FLOAT y)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:996
int left
The left.
Definition: fx_coordinates.h:599
Definition: fx_basic.h:1288
CFX_PSVTemplate< FX_FLOAT > CFX_SizeF
Type definition for size class for float.
Definition: fx_coordinates.h:220
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:956
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:522
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:663
void UpdateRect(FX_FLOAT x, FX_FLOAT y)
Update the rectangle to contain the specified point.
#define FXSYS_assert
Assertion.
Definition: fx_system.h:779
FXT_PSV & operator+=(const FXT_PSV &obj)
Overload operator +=.
Definition: fx_coordinates.h:118
CFX_PSVTemplate< FX_INT32 > * FX_LPPOINT
Type definition for pointer to integer point.
Definition: fx_coordinates.h:226
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:457
Definition: fx_coordinates.h:596
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:977
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:739
friend FXT_PSV operator/(const FXT_PSV &obj, BaseType lamda)
Overload operator /.
Definition: fx_coordinates.h:206
friend FX_BOOL operator !=(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator !=.
Definition: fx_coordinates.h:161
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:1007
friend FX_BOOL operator==(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator ==.
Definition: fx_coordinates.h:152
FX_SHORT Top
The top.
Definition: fx_coordinates.h:760
CFX_RTemplate< FX_INT32 > const * FX_LPCRECT
Type definition for constant pointer to integer rectangle.
Definition: fx_coordinates.h:465
void Copy(const CFX_Matrix &m)
Copy coefficients from another matrix.
Definition: fx_coordinates.h:1206
CFX_VTemplate< FX_FLOAT > CFX_VectorF
Vector class for float.
Definition: fx_coordinates.h:304
FX_FLOAT GetB() const
Get the coefficient b.
Definition: fx_coordinates.h:1592
friend FXT_PSV operator+(const FXT_PSV &obj1, const FXT_PSV &obj2)
Overload operator +.
Definition: fx_coordinates.h:170
FX_FLOAT f
The coefficient f.
Definition: fx_coordinates.h:1634
FX_FLOAT right
The right.
Definition: fx_coordinates.h:1040
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:794
CFX_PSVTemplate< FX_INT32 > CFX_Size
Type definition for size class for integer.
Definition: fx_coordinates.h:218
Definition: fx_coordinates.h:31
FX_FLOAT bottom
The bottom.
Definition: fx_coordinates.h:1042
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:703
void Intersect(const FX_RECT &src)
Intersect with a rect.
Definition: fx_coordinates.h:32
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:216
FX_FLOAT left
The left.
Definition: fx_coordinates.h:1038
CFX_ETemplate< FX_FLOAT > CFX_EllipseF
Type definition for ellipse class for float.
Definition: fx_coordinates.h:524
Definition: fx_coordinates.h:35
void Reset()
Reset rectangle, set coordinates to 0.
Definition: fx_coordinates.h:844
void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended=false)
Rotate the matrix.
BaseType y
y coordinate of the point.
Definition: fx_coordinates.h:211
FX_FLOAT TransformXDistance(FX_FLOAT dx) const
Transform a x-distance.
Definition: fx_coordinates.h:1076
void Set(const FXT_PSV &psv)
Set values.
Definition: fx_coordinates.h:85
#define FXSYS_sqrt
Calculate the square root. FXSYS_sqrt(x) means sqrt(x).
Definition: fx_system.h:1375
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:824
FX_BOOL operator==(const CFX_Matrix &src) const
Compare(==) operator overload. Compare two matrixs.
Definition: fx_coordinates.h:1104
void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended=false)
Scale the matrix.
FX_FLOAT top
The top.
Definition: fx_coordinates.h:1044
FX_RECT()
Construct a rect not initialized.
Definition: fx_coordinates.h:610
FX_FLOAT GetE() const
Get the coefficient e.
Definition: fx_coordinates.h:1613
CFX_RRTemplate< FX_INT32 > CFX_RoundRect
Type definition for round-corner rectangle class for integer.
Definition: fx_coordinates.h:549
void Translate(FX_FLOAT e, FX_FLOAT f)
Translate rectangle.
Definition: fx_coordinates.h:1025
CFX_RTemplate< FX_FLOAT > CFX_RectF
Type definition for rectangle class for float.
Definition: fx_coordinates.h:459
baseType yRadius
y radius of round corner. This must not exceed the half height.
Definition: fx_coordinates.h:545
void TransformRoundRect(CFX_RoundRectF &rr) const
Transform a round rectangle.
friend FXT_PSV operator *(const FXT_PSV &obj, BaseType lamda)
Overload operator *.
Definition: fx_coordinates.h:188
void Deflate(const CFX_FloatRect &rt)
Decreases the width and height of the rectangle.
Definition: fx_coordinates.h:1015
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:1094
CFX_PSVTemplate(const CFX_PSVTemplate &other)
Copy constructor.
Definition: fx_coordinates.h:67
Definition: fx_coordinates.h:771
FX_SHORT Right
The right.
Definition: fx_coordinates.h:762
FX_FLOAT d
The coefficient d.
Definition: fx_coordinates.h:1630
FX_BOOL IsIdentity() const
Determine whether a matrix is an identity transformation or not.
Definition: fx_coordinates.h:1213
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:693
Definition: fx_coordinates.h:755
FX_FLOAT e
The coefficient e.
Definition: fx_coordinates.h:1632
void Subtract(BaseType x, BaseType y)
Subtract a point.
Definition: fx_coordinates.h:103
CFX_VTemplate< FX_INT32 > CFX_Vector
Vector class for integer.
Definition: fx_coordinates.h:302