nx_server_plugin_sdk 1.0 Server Plugin 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::sdk::analytics {
8
9 struct Rect
10 {
12 Rect() = default;
13
14 Rect(float x, float y, float width, float height): x(x), y(y), width(width), height(height) {}
15
16 Rect(Point topLeft, float width, float height):
17 x(topLeft.x), y(topLeft.y), width(width), height(height)
18 {
19 }
20
25 float x = -1;
26
31 float y = -1;
32
37 float width = -1;
38
43 float height = -1;
44
50 Point center() const { return Point(x + width / 2, y + height / 2); }
51
52 bool isValid() const
53 {
54 return x >= 0 && y >= 0 && width >= 0 && height >= 0
55 && x + width <= 1 && y + height <= 1;
56 }
57 };
58
59 } // namespace nx::sdk::analytics
nx::sdk::analytics::Rect::x
float x
Definition: rect.h:25
nx::sdk::analytics::Point::y
float y
Definition: point.h:21
nx::sdk::analytics::Rect::width
float width
Definition: rect.h:37
nx::sdk::analytics::Rect::y
float y
Definition: rect.h:31
nx::sdk::analytics::Rect::center
Point center() const
Definition: rect.h:50
nx::sdk::analytics
Definition: consuming_device_agent.cpp:25
nx::sdk::analytics::Rect::Rect
Rect()=default
nx::sdk::analytics::Rect::height
float height
Definition: rect.h:43
nx::sdk::analytics::Point
Definition: point.h:7
nx::sdk::analytics::Point::x
float x
Definition: point.h:16
nx::sdk::analytics::Rect
Definition: rect.h:9