2 * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 * John Scipione, jscipione@gmail.com
17 #include <SupportDefs.h>
21 const BPoint
B_ORIGIN(0, 0);
25 BPoint::ConstrainTo(BRect rect
)
27 x
= std::max(std::min(x
, rect
.right
), rect
.left
);
28 y
= std::max(std::min(y
, rect
.bottom
), rect
.top
);
33 BPoint::PrintToStream() const
35 printf("BPoint(x:%.0f, y:%.0f)\n", x
, y
);
40 BPoint::operator-() const
42 return BPoint(-x
, -y
);
47 BPoint::operator+(const BPoint
& other
) const
49 return BPoint(x
+ other
.x
, y
+ other
.y
);
54 BPoint::operator-(const BPoint
& other
) const
56 return BPoint(x
- other
.x
, y
- other
.y
);
61 BPoint::operator+=(const BPoint
& other
)
71 BPoint::operator-=(const BPoint
& other
)
81 BPoint::operator!=(const BPoint
& other
) const
83 return x
!= other
.x
|| y
!= other
.y
;
88 BPoint::operator==(const BPoint
& other
) const
90 return x
== other
.x
&& y
== other
.y
;