nx_metadata_sdk  1.0
Metadata SDK
rect.h
1 // Copyright 2018-present Network Optix, Inc. Licensed under MPL 2.0: www.mozilla.org/MPL/2.0/
2 
3 #pragma once
4 
5 #include <nx/sdk/analytics/point.h>
6 
7 namespace nx {
8 namespace sdk {
9 namespace analytics {
10 
11 struct Rect
12 {
14  Rect() = default;
15 
16  Rect(float x, float y, float width, float height): x(x), y(y), width(width), height(height) {}
17 
18  Rect(Point topLeft, float width, float height):
19  x(topLeft.x), y(topLeft.y), width(width), height(height)
20  {
21  }
22 
27  float x = -1;
28 
33  float y = -1;
34 
39  float width = -1;
40 
45  float height = -1;
46 
52  Point center() const { return Point(x + width / 2, y + height / 2); }
53 
54  bool isValid() const
55  {
56  return x >= 0 && y >= 0 && width >= 0 && height >= 0
57  && x + width <= 1 && y + height <= 1;
58  }
59 };
60 
61 } // namespace analytics
62 } // namespace sdk
63 } // namespace nx
float x
Definition: rect.h:27
float y
Definition: point.h:23
float width
Definition: rect.h:39
float y
Definition: rect.h:33
Point center() const
Definition: rect.h:52
float height
Definition: rect.h:45
Definition: apple_utils.h:6
Definition: point.h:9
float x
Definition: point.h:18
Definition: rect.h:11