2009-12-04 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / point.h
blobb68208e6179df045a529451bf64e1854f9677e15
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * point.h
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __MOON_POINT_H__
12 #define __MOON_POINT_H__
14 #include <glib.h>
15 #include <cairo.h>
16 #include <math.h>
18 /* @IncludeInKinds */
19 struct Point {
20 public:
21 double x, y;
23 Point () : x(0), y(0) {}
25 Point (double x, double y)
27 this->x = x;
28 this->y = y;
31 Point operator+ (const Point &point)
33 return Point (x + point.x,
34 y + point.y);
37 Point operator- (const Point &point)
39 return Point (x - point.x,
40 y - point.y);
43 Point operator* (double v)
45 return Point (x * v, y * v);
48 bool operator == (const Point &point) const
50 return fabs (point.x-x) < DBL_EPSILON && fabs (point.y-y) < DBL_EPSILON;
53 bool operator != (const Point &point) const
55 return !(*this == point);
58 Point Transform (cairo_matrix_t *matrix);
61 // FromStr
62 // Parses @s and return a new point in @p. Returns true if
63 // this was successful, false otherwise.
65 static bool FromStr (const char *s, Point *p);
68 #endif /* __MOON_POINT_H__ */