Flutter Engine
The Flutter Engine
Point.h
Go to the documentation of this file.
1// Copyright 2023 Google LLC
2// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
3
4#ifndef Point_DEFINED
5#define Point_DEFINED
6
7#include <cstdint>
8
9namespace bentleyottmann {
10struct Point {
11 int32_t x;
12 int32_t y;
13
14 // Relation for ordering events.
15 friend bool operator<(const Point& p0, const Point& p1);
16 friend bool operator>(const Point& p0, const Point& p1);
17 friend bool operator>=(const Point& p0, const Point& p1);
18 friend bool operator<=(const Point& p0, const Point& p1);
19
20 // Equality
21 friend bool operator==(const Point& p0, const Point& p1);
22 friend bool operator!=(const Point& p0, const Point& p1);
23
24 // Extremes
25 static Point Smallest();
26 static Point Largest();
27 static bool DifferenceTooBig(Point p0, Point p1);
28
29 // Terms
30 friend Point operator+(const Point& p0, const Point& p1) {
31 return {p0.x + p1.x, p0.y + p1.y};
32 }
33 friend Point operator-(const Point& p0, const Point& p1) {
34 return {p0.x - p1.x, p0.y - p1.y};
35 }
36};
37} // namespace bentleyottmann
38#endif // Point_DEFINED
friend bool operator>(const Point &p0, const Point &p1)
Definition: Point.cpp:16
static Point Smallest()
Definition: Point.cpp:36
friend bool operator==(const Point &p0, const Point &p1)
Definition: Point.cpp:28
static bool DifferenceTooBig(Point p0, Point p1)
Definition: Point.cpp:46
friend bool operator>=(const Point &p0, const Point &p1)
Definition: Point.cpp:20
static Point Largest()
Definition: Point.cpp:41
friend bool operator<(const Point &p0, const Point &p1)
Definition: Point.cpp:12
friend bool operator<=(const Point &p0, const Point &p1)
Definition: Point.cpp:24
friend Point operator+(const Point &p0, const Point &p1)
Definition: Point.h:30
friend Point operator-(const Point &p0, const Point &p1)
Definition: Point.h:33
friend bool operator!=(const Point &p0, const Point &p1)
Definition: Point.cpp:32