TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
Rect.h
Go to the documentation of this file.
1 #pragma once
2 
13 #include <SDL2/SDL.h>
14 #include <algorithm>
15 #include "Point.h"
16 
17 struct Rect
18 {
19  int x, y, width, height;
20 
21  static Rect fromCoords(Point p1, Point p2)
22  {
23  int xMin = std::min(p1.x, p2.x);
24  int yMin = std::min(p1.y, p2.y);
25 
26  return {
27  xMin,
28  yMin,
29  std::abs(p1.x - p2.x),
30  std::abs(p1.y - p2.y)};
31  }
32 
33  operator SDL_Rect() const
34  {
35  return SDL_Rect{
36  x, y, width, height};
37  }
38 };
static Rect fromCoords(Point p1, Point p2)
Definition: Rect.h:21
int x
Definition: Point.h:18
int y
Definition: Point.h:18
int y
Definition: Rect.h:19
int height
Definition: Rect.h:19
int width
Definition: Rect.h:19
int x
Definition: Rect.h:19
Definition: Point.h:16
Definition: Rect.h:17