Libraries/Graphics/src/include/Graphics/Types.h
Go to the documentation of this file.
1 /****
2  * Types.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: May 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include <WString.h>
25 #include <Data/CStringArray.h>
26 #include <Data/BitSet.h>
27 #include <Data/Range.h>
28 #include <memory>
29 #include <cassert>
30 #include "Colors.h"
31 
32 namespace Graphics
33 {
37 static constexpr uint8_t PIN_NONE{255};
38 
42 using AssetID = uint16_t;
43 
47 enum class Orientation {
48  normal,
49  deg0 = normal,
50  deg90,
51  deg180,
52  deg270,
53 };
54 
55 enum class Align {
56  Near, // 0
57  Centre, // 1
58  Far, // 2
59  Left = Near, // 0
60  Top = Near, // 0
61  Center = Centre, // 1
62  Right = Far, // 2
63  Bottom = Far, // 2
64 };
65 
71 enum class Origin {
72  E, // 0 degrees
73  NE, // 45
74  N, // 90
75  NW, // 135
76  W, // 180
77  SW, // 225
78  S, // 270
79  SE, // 315
80  Centre,
81  TopLeft = NW,
82  Top = N,
83  TopRight = NE,
84  Left = W,
85  Center = Centre,
86  Right = E,
87  BottomLeft = SW,
88  Bottom = S,
89  BottomRight = SE,
90 };
91 
97 inline Origin opposite(Origin o)
98 {
99  return (o == Origin::Centre) ? o : Origin((unsigned(o) + 4) % 8);
100 }
101 
105 struct Size {
106  uint16_t w{0};
107  uint16_t h{0};
108 
109  constexpr Size()
110  {
111  }
112 
113  constexpr Size(uint16_t w, uint16_t h) : w(w), h(h)
114  {
115  }
116 
117  String toString() const;
118 };
119 
120 static_assert(sizeof(Size) == 4, "Size too big");
121 
122 constexpr inline Size rotate(Size size, Orientation orientation)
123 {
124  if(orientation == Orientation::deg90 || orientation == Orientation::deg270) {
125  std::swap(size.w, size.h);
126  }
127  return size;
128 }
129 
133 template <typename T> struct TPoint {
134  T x{0};
135  T y{0};
136 
137  constexpr TPoint()
138  {
139  }
140 
141  constexpr TPoint(T x, T y) : x(x), y(y)
142  {
143  }
144 
148  template <typename Q> explicit constexpr TPoint(TPoint<Q> pt) : x(pt.x), y(pt.y)
149  {
150  }
151 
152  explicit constexpr TPoint(Size sz) : x(sz.w), y(sz.h)
153  {
154  }
155 
156  explicit operator bool() const
157  {
158  return x != 0 || y != 0;
159  }
160 
161  template <typename Q> bool operator==(TPoint<Q> other) const
162  {
163  return x == other.x && y == other.y;
164  }
165 
166  template <typename Q> bool operator!=(TPoint<Q> other) const
167  {
168  return !operator==(other);
169  }
170 
171  template <typename Q> constexpr TPoint& operator+=(TPoint<Q> other)
172  {
173  x += other.x;
174  y += other.y;
175  return *this;
176  }
177 
178  template <typename Q> constexpr TPoint& operator-=(TPoint<Q> other)
179  {
180  x -= other.x;
181  y -= other.y;
182  return *this;
183  }
184 
185  template <typename Q> constexpr TPoint& operator*=(TPoint<Q> other)
186  {
187  x *= other.x;
188  y *= other.y;
189  return *this;
190  }
191 
192  template <typename Q> constexpr TPoint& operator*=(Q scalar)
193  {
194  x *= scalar;
195  y *= scalar;
196  return *this;
197  }
198 
199  template <typename Q> constexpr TPoint& operator/=(TPoint<Q> other)
200  {
201  x /= other.x;
202  y /= other.y;
203  return *this;
204  }
205 
206  template <typename Q> constexpr TPoint& operator/=(Q scalar)
207  {
208  x /= scalar;
209  y /= scalar;
210  return *this;
211  }
212 
213  template <typename Q> constexpr TPoint& operator%=(TPoint<Q> other)
214  {
215  x %= other.x;
216  y %= other.y;
217  return *this;
218  }
219 
220  template <typename Q> constexpr TPoint& operator%=(Q scalar)
221  {
222  x %= scalar;
223  y %= scalar;
224  return *this;
225  }
226 
227  explicit operator uint32_t() const
228  {
229  return (y << 16) | x;
230  }
231 
232  String toString() const
233  {
234  char buf[16];
235  m_snprintf(buf, sizeof(buf), "%d, %d", x, y);
236  return buf;
237  }
238 };
239 
240 template <typename T, typename Q> constexpr TPoint<T> operator+(TPoint<T> pt, const Q& other)
241 {
242  pt += other;
243  return pt;
244 }
245 
246 template <typename T, typename Q> constexpr TPoint<T> operator-(TPoint<T> pt, const Q& other)
247 {
248  pt -= other;
249  return pt;
250 }
251 
252 template <typename T, typename Q> constexpr TPoint<T> operator*(TPoint<T> pt, const Q& other)
253 {
254  pt *= other;
255  return pt;
256 }
257 
258 template <typename T> constexpr TPoint<T> operator*(TPoint<T> pt, const Size& other)
259 {
260  return pt * TPoint<T>(other);
261 }
262 
263 template <typename T, typename Q> constexpr TPoint<T> operator/(TPoint<T> pt, const Q& other)
264 {
265  pt /= other;
266  return pt;
267 }
268 
269 template <typename T> constexpr TPoint<T> operator/(TPoint<T> pt, const Size& other)
270 {
271  return pt / TPoint<T>(other);
272 }
273 
274 template <typename T, typename Q> constexpr TPoint<T> operator%(TPoint<T> pt, const Q& other)
275 {
276  pt %= other;
277  return pt;
278 }
279 
280 using Point = TPoint<int16_t>;
281 using IntPoint = TPoint<int>;
283 
287 struct Rect {
288  int16_t x{0};
289  int16_t y{0};
290  uint16_t w{0};
291  uint16_t h{0};
292 
293  constexpr Rect()
294  {
295  }
296 
297  constexpr Rect(int16_t x, int16_t y, uint16_t w, uint16_t h) : x(x), y(y), w(w), h(h)
298  {
299  }
300 
301  constexpr Rect(int16_t x, int16_t y, Size size) : x(x), y(y), w(size.w), h(size.h)
302  {
303  }
304 
305  constexpr Rect(Point pt, Size size) : x(pt.x), y(pt.y), w(size.w), h(size.h)
306  {
307  }
308 
309  constexpr Rect(Point pt, uint16_t w, uint16_t h) : x(pt.x), y(pt.y), w(w), h(h)
310  {
311  }
312 
313  constexpr Rect(Size size) : Rect({}, size)
314  {
315  }
316 
317  constexpr Rect(Point pt1, Point pt2)
318  {
319  if(pt1.x > pt2.x) {
320  std::swap(pt1.x, pt2.x);
321  }
322  if(pt1.y > pt2.y) {
323  std::swap(pt1.y, pt2.y);
324  }
325  x = pt1.x;
326  y = pt1.y;
327  w = 1 + pt2.x - pt1.x;
328  h = 1 + pt2.y - pt1.y;
329  }
330 
331  constexpr Rect(Point pt, Size size, Origin origin)
332  {
333  switch(origin) {
334  case Origin::TopLeft:
335  *this = Rect(pt, size);
336  break;
337  case Origin::Top:
338  *this = Rect(pt.x - size.w / 2, pt.y, size);
339  break;
340  case Origin::TopRight:
341  *this = Rect(pt.x - size.w, pt.y, size);
342  break;
343  case Origin::Left:
344  *this = Rect(pt.x, pt.y - size.h / 2, size);
345  break;
346  case Origin::Centre:
347  *this = Rect(pt.x - size.w / 2, pt.y - size.h / 2, size);
348  break;
349  case Origin::Right:
350  *this = Rect(pt.x - size.w, pt.y - size.h / 2, size);
351  break;
352  case Origin::BottomLeft:
353  *this = Rect(pt.x, pt.y - size.h, size);
354  break;
355  case Origin::Bottom:
356  *this = Rect(pt.x - size.w / 2, pt.y - size.h, size);
357  break;
358  case Origin::BottomRight:
359  *this = Rect(pt.x - size.w, pt.y - size.h, size);
360  break;
361  default:
362  *this = Rect(pt, size);
363  }
364  }
365 
366  Point getPoint(Origin origin) const
367  {
368  switch(origin) {
369  case Origin::E:
370  return Point(right(), centre().y);
371  case Origin::NE:
372  return topRight();
373  case Origin::N:
374  return Point(centre().x, top());
375  case Origin::NW:
376  return topLeft();
377  case Origin::W:
378  return Point(left(), centre().y);
379  case Origin::SW:
380  return bottomLeft();
381  case Origin::S:
382  return Point(centre().x, bottom());
383  case Origin::SE:
384  return bottomRight();
386  return centre();
387  default:
388  return topLeft();
389  }
390  }
391 
392  Point operator[](Origin origin) const
393  {
394  return getPoint(origin);
395  }
396 
397  int16_t left() const
398  {
399  return x;
400  }
401 
402  int16_t right() const
403  {
404  return x + w - 1;
405  }
406 
407  int16_t top() const
408  {
409  return y;
410  }
411 
412  int16_t bottom() const
413  {
414  return y + h - 1;
415  }
416 
417  Point topLeft() const
418  {
419  return Point{left(), top()};
420  }
421 
422  Point topRight() const
423  {
424  return Point{right(), top()};
425  }
426 
427  Point bottomLeft() const
428  {
429  return Point{left(), bottom()};
430  }
431 
432  Point bottomRight() const
433  {
434  return Point{right(), bottom()};
435  }
436 
437  Point centre() const
438  {
439  return Point(x + w / 2, y + h / 2);
440  }
441 
442  Point center() const
443  {
444  return centre();
445  }
446 
447  Size size() const
448  {
449  return Size{w, h};
450  }
451 
452  explicit operator bool() const
453  {
454  return w != 0 && h != 0;
455  }
456 
457  bool operator==(const Rect& other) const
458  {
459  return x == other.x && y == other.y && w == other.w && h == other.h;
460  }
461 
462  bool operator!=(const Rect& other) const
463  {
464  return !operator==(other);
465  }
466 
467  Rect& operator+=(const Point& off)
468  {
469  x += off.x;
470  y += off.y;
471  return *this;
472  }
473 
474  Rect& operator-=(const Point& off)
475  {
476  x -= off.x;
477  y -= off.y;
478  return *this;
479  }
480 
481  bool contains(Point pt) const
482  {
483  return pt.x >= left() && pt.x <= right() && pt.y >= top() && pt.y <= bottom();
484  }
485 
486  int16_t clipX(int16_t x) const
487  {
488  if(x < left()) {
489  return left();
490  }
491  if(x > right()) {
492  return right();
493  }
494  return x;
495  }
496 
497  int16_t clipY(int16_t y) const
498  {
499  if(y < top()) {
500  return top();
501  }
502  if(y > bottom()) {
503  return bottom();
504  }
505  return y;
506  }
507 
508  Point clip(Point pt) const
509  {
510  return Point{clipX(pt.x), clipY(pt.y)};
511  }
512 
513  bool intersects(const Rect& r) const
514  {
515  return right() >= r.left() && left() <= r.right() && bottom() >= r.top() && top() <= r.bottom();
516  }
517 
521  Rect& clip(const Rect& r)
522  {
523  if(intersects(r)) {
524  Point pt1{std::max(x, r.x), std::max(y, r.y)};
525  Point pt2{std::min(right(), r.right()), std::min(bottom(), r.bottom())};
526  if(pt1.x <= pt2.x && pt1.y <= pt2.y) {
527  *this = Rect{pt1, pt2};
528  return *this;
529  }
530  }
531  *this = Rect{};
532  return *this;
533  }
534 
538  Rect& operator+=(const Rect& r)
539  {
540  if(!*this) {
541  *this = r;
542  } else if(r) {
543  Point pt1{std::min(left(), r.left()), std::min(top(), r.top())};
544  Point pt2{std::max(right(), r.right()), std::max(bottom(), r.bottom())};
545  *this = Rect{pt1, pt2};
546  }
547  return *this;
548  }
549 
550  void inflate(int16_t cw, int16_t ch)
551  {
552  x -= cw;
553  w += cw + cw;
554  y -= ch;
555  h += ch + ch;
556  }
557 
558  void inflate(int16_t cwh)
559  {
560  inflate(cwh, cwh);
561  }
562 
563  String toString() const;
564 };
565 
566 static_assert(sizeof(Rect) == 8, "Rect too big");
567 
568 template <typename T> Rect operator+(const Rect& rect, const T& other)
569 {
570  Rect r(rect);
571  r += other;
572  return r;
573 }
574 
575 inline Rect operator-(const Rect& rect, const Point& offset)
576 {
577  Rect r(rect);
578  r -= offset;
579  return r;
580 }
581 
582 inline Rect intersect(Rect r1, const Rect& r2)
583 {
584  return r1.clip(r2);
585 }
586 
592 class Region
593 {
594 public:
595  constexpr Region() = default;
596  constexpr Region(const Region& other) = default;
597 
598  constexpr Region(const Rect& r) : rects{r}
599  {
600  }
601 
607  Region& operator+=(const Rect& r)
608  {
609  rects[0] += rects[1] + rects[2] + rects[3];
610  rects[1] = rects[2] = rects[3] = Rect{};
611  return *this;
612  }
613 
620  Region& operator-=(const Rect& r)
621  {
622  Rect u = bounds();
623  auto i = intersect(u, r);
624  if(!i) {
625  return *this;
626  }
627 
628  clear();
629 
630  auto u2 = u.bottomRight();
631  auto i2 = i.bottomRight();
632 
633  // #1
634  if(u.y < i.y) {
635  rects[0] = Rect(u.x, u.y, u.w, i.y - u.y);
636  }
637  // #2
638  if(u2.y > i2.y) {
639  rects[1] = Rect(u.x, 1 + i2.y, u.w, u2.y - i2.y);
640  }
641  // #3
642  if(u.x < i.x) {
643  rects[2] = Rect(u.x, i.y, i.x - u.x, i.h);
644  }
645  // #4
646  if(u2.x > i2.x) {
647  rects[3] = Rect(1 + i2.x, i.y, u2.x - i2.x, i.h);
648  }
649 
650  return *this;
651  }
652 
653  Rect bounds() const
654  {
655  return rects[0] + rects[1] + rects[2] + rects[3];
656  }
657 
658  void clear()
659  {
660  memset(&rects, 0, sizeof(rects));
661  }
662 
663  explicit operator bool() const
664  {
665  return bool(rects[0]) || bool(rects[1]) || bool(rects[2]) || bool(rects[3]);
666  }
667 
668  String toString() const;
669 
670  Rect rects[4]{};
671 };
672 
673 inline Region operator-(const Region& rgn, const Rect& r)
674 {
675  Region rgn2{rgn};
676  rgn2 -= r;
677  return rgn2;
678 }
679 
683 struct Location {
687  Rect dest;
688 
697  Rect source;
698 
703 
704  Point destPos() const
705  {
706  return dest.topLeft() + pos;
707  }
708 
709  Point sourcePos() const
710  {
711  return source.topLeft() + pos;
712  }
713 
714  String toString() const;
715 };
716 
717 using Range = TRange<uint16_t>;
718 
719 class ColorRange
720 {
721 public:
722  ColorRange()
723  {
724  }
725 
726  static Color random(uint8_t alpha = 0xff)
727  {
728  return makeColor(TRange<uint32_t>(0, 0xffffff).random(), alpha);
729  }
730 };
731 
732 class Scale
733 {
734 public:
735  constexpr Scale() : xscale(0), yscale(0)
736  {
737  }
738 
739  constexpr Scale(uint8_t sxy) : Scale(sxy, sxy)
740  {
741  }
742 
743  constexpr Scale(uint8_t sx, uint8_t sy) : xscale(sx > 0 ? sx - 1 : 0), yscale(sy > 0 ? sy - 1 : 0)
744  {
745  }
746 
747  constexpr bool operator==(const Scale& other)
748  {
749  return xscale == other.xscale && yscale == other.yscale;
750  }
751 
752  constexpr bool operator!=(const Scale& other)
753  {
754  return !operator==(other);
755  }
756 
757  constexpr uint8_t scaleX() const
758  {
759  return 1 + xscale;
760  }
761 
762  constexpr uint16_t scaleX(uint16_t x) const
763  {
764  return x * scaleX();
765  }
766 
767  constexpr uint16_t unscaleX(uint16_t x) const
768  {
769  return x / scaleX();
770  }
771 
772  constexpr uint8_t scaleY() const
773  {
774  return 1 + yscale;
775  }
776 
777  constexpr uint16_t scaleY(uint16_t y) const
778  {
779  return y * scaleY();
780  }
781 
782  constexpr uint16_t unscaleY(uint16_t y) const
783  {
784  return y / scaleY();
785  }
786 
787  constexpr Size scale() const
788  {
789  return {scaleX(), scaleY()};
790  }
791 
792  constexpr Size scale(Size size) const
793  {
794  return {scaleX(size.w), scaleY(size.h)};
795  }
796 
797  constexpr Size unscale(Size size) const
798  {
799  return {unscaleX(size.w), unscaleY(size.h)};
800  }
801 
802  explicit operator bool() const
803  {
804  return xscale != 0 || yscale != 0;
805  }
806 
807  String toString() const;
808 
809 private:
810  uint8_t xscale : 4;
811  uint8_t yscale : 4;
812 };
813 
814 #define GRAPHICS_FONT_STYLE(XX) \
815  XX(Bold, "") \
816  XX(Italic, "") \
817  XX(Underscore, "") \
818  XX(Overscore, "") \
819  XX(Strikeout, "") \
820  XX(DoubleUnderscore, "") \
821  XX(DoubleOverscore, "") \
822  XX(DoubleStrikeout, "") \
823  XX(DotMatrix, "Draw only top-left dot in scaled glyphs") \
824  XX(HLine, "Draw only top line in scaled glyphs") \
825  XX(VLine, "Draw only left line in scaled glyphs")
826 
827 enum class FontStyle {
828 #define XX(name, desc) name,
830 #undef XX
831 };
832 
834 
838 struct GlyphMetrics {
839  uint8_t width;
840  uint8_t height;
841  int8_t xOffset;
842  int8_t yOffset;
843  uint8_t advance;
844 
845  Size size() const
846  {
847  return Size{width, height};
848  }
849 };
850 
854 inline uint16_t originToDegrees(Origin origin)
855 {
856  return 45 * (unsigned(origin) % 8);
857 }
858 
863 
867 uint16_t normaliseAngle(int angle);
868 
869 } // namespace Graphics
870 
875 
876 template <typename T> inline String toString(Graphics::TPoint<T> pt)
877 {
878  return pt.toString();
879 }
880 
882 {
883  return r.toString();
884 }
885 
887 {
888  return loc.toString();
889 }
890 
892 {
893  return Graphics::Point(sz.w, sz.h).toString();
894 }
895 
897 {
898  return toString(Graphics::Size(scale.scaleX(), scale.scaleY()));
899 }
int16_t bottom() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:431
bool contains(Point pt) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:500
Size size() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:864
void inflate(int16_t cw, int16_t ch)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:569
String toString() const
uint16_t w
Definition: Libraries/Graphics/src/include/Graphics/Types.h:125
uint16_t normaliseAngle(int angle)
Make 0 <= angle < 360.
T x
Definition: Libraries/Graphics/src/include/Graphics/Types.h:153
String toString() const
Rect & operator+=(const Point &off)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:486
Origin degreesToOrigin(uint16_t angle)
Get origin closest to given angle (expressed in degrees)
Rect rects[4]
Definition: Libraries/Graphics/src/include/Graphics/Types.h:689
BitSet< uint16_t, FontStyle, 10 > FontStyles
Definition: Libraries/Graphics/src/include/Graphics/Types.h:852
uint16_t AssetID
Numeric identifiers for re-useable objects.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:61
int16_t right() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:421
Point pos
Position relative to dest/source top-left corner.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:721
String toString() const
T y
Definition: Libraries/Graphics/src/include/Graphics/Types.h:154
uint8_t advance
Distance to next character.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:862
Location and size of rectangular area (x, y, w, h)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:306
Point bottomLeft() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:446
The String class.
Definition: WString.h:136
constexpr uint8_t scaleX() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:776
static Color random(uint8_t alpha=0xff)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:745
bool intersects(const Rect &r) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:532
ColorRange()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:741
void clear()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:677
FontStyle
Definition: Libraries/Graphics/src/include/Graphics/Types.h:846
Definition: Libraries/Graphics/src/include/Graphics/Types.h:738
constexpr Rect()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:312
Point topRight() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:441
constexpr Region()=default
constexpr Scale()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:754
Identifies position within bounding rectangle.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:702
Manage a range of numbers between specified limits.
Definition: Range.h:21
uint8_t height
Height of glyph.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:859
constexpr uint16_t unscaleY(uint16_t y) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:801
int m_snprintf(char *buf, int length, const char *fmt,...)
Point center() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:461
constexpr TPoint & operator-=(TPoint< Q > other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:197
static constexpr uint8_t PIN_NONE
Undefined I/O pin value.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:56
String toString() const
constexpr Color makeColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Function to create a custom colour.
Definition: Colors.h:241
Size of rectangular area (width x height)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:124
constexpr TPoint & operator+=(TPoint< Q > other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:190
constexpr Size scale() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:806
constexpr TPoint< T > operator+(TPoint< T > pt, const Q &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:259
Rect bounds() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:672
Point operator[](Origin origin) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:411
constexpr TPoint< T > operator*(TPoint< T > pt, const Q &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:271
Definition: Virtual.h:30
TPoint< int16_t > Point
Definition: Libraries/Graphics/src/include/Graphics/Types.h:299
int16_t clipX(int16_t x) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:505
bool operator!=(TPoint< Q > other) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:185
constexpr Size unscale(Size size) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:816
uint16_t h
Definition: Libraries/Graphics/src/include/Graphics/Types.h:126
constexpr TPoint< T > operator%(TPoint< T > pt, const Q &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:293
int16_t x
Definition: Libraries/Graphics/src/include/Graphics/Types.h:307
Point bottomRight() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:451
int16_t y
Definition: Libraries/Graphics/src/include/Graphics/Types.h:308
Origin
Points on a compass.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:90
TPoint< int > IntPoint
Definition: Libraries/Graphics/src/include/Graphics/Types.h:300
constexpr uint8_t scaleY() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:791
int8_t xOffset
Glyph position relative to cursor.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:860
Point centre() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:456
constexpr TPoint< T > operator/(TPoint< T > pt, const Q &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:282
#define GRAPHICS_FONT_STYLE(XX)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:833
An (x, y) display coordinate.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:152
constexpr Rect(Point pt, Size size, Origin origin)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:350
Align
Definition: Libraries/Graphics/src/include/Graphics/Types.h:74
Point sourcePos() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:728
uint8_t width
Width of glyph.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:858
Point destPos() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:723
Definition: Libraries/Graphics/src/include/Graphics/Types.h:751
Orientation
Defines orientation of display.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:66
constexpr TPoint & operator%=(TPoint< Q > other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:232
int16_t left() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:416
String toString() const
Point getPoint(Origin origin) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:385
String toString(Graphics::Orientation orientation)
Region & operator+=(const Rect &r)
Add rectangle to this region.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:626
constexpr TPoint & operator/=(TPoint< Q > other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:218
bool operator==(const Rect &other) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:476
Point topLeft() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:436
Rect dest
Where to write pixels on surface.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:706
constexpr bool operator==(const Scale &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:766
uint16_t originToDegrees(Origin origin)
Get corresponding angle for given origin.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:873
constexpr Size rotate(Size size, Orientation orientation)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:141
Size size() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:466
constexpr bool operator!=(const Scale &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:771
uint16_t w
Definition: Libraries/Graphics/src/include/Graphics/Types.h:309
Rect source
Reference source area.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:716
Rect & operator-=(const Point &off)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:493
int8_t yOffset
Distance from upper-left corner to baseline.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:861
bool operator!=(const Rect &other) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:481
Represents the intersection of two rectangles.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:611
constexpr Size()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:128
Point clip(Point pt) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:527
uint16_t h
Definition: Libraries/Graphics/src/include/Graphics/Types.h:310
int16_t clipY(int16_t y) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:516
Region & operator-=(const Rect &r)
Remove rectangle from this region.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:639
Origin opposite(Origin o)
Get the origin for the opposite side of the rectangle.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:116
int16_t top() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:426
constexpr TPoint & operator*=(TPoint< Q > other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:204
String toString() const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:251
constexpr TPoint< T > operator-(TPoint< T > pt, const Q &other)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:265
constexpr uint16_t unscaleX(uint16_t x) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:786
constexpr TPoint()
Definition: Libraries/Graphics/src/include/Graphics/Types.h:156
bool operator==(TPoint< Q > other) const
Definition: Libraries/Graphics/src/include/Graphics/Types.h:180
Color
Standard colour definitions.
Definition: Colors.h:227
Rect intersect(Rect r1, const Rect &r2)
Definition: Libraries/Graphics/src/include/Graphics/Types.h:601