2 Copyright (C) 2011-2013 Paul Davis
3 Author: Carl Hetherington <cth@carlh.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __CANVAS_TYPES_H__
21 #define __CANVAS_TYPES_H__
26 #include <boost/optional.hpp>
28 #include <cairomm/refptr.h>
34 namespace ArdourCanvas
38 typedef double Distance;
39 typedef uint32_t Color;
41 extern Coord const COORD_MAX;
50 Duple (Coord x_, Coord y_)
58 Duple translate (Duple) const;
62 extern Duple operator- (Duple const &);
63 extern Duple operator+ (Duple const &, Duple const &);
64 extern bool operator== (Duple const &, Duple const &);
65 extern Duple operator- (Duple const &, Duple const &);
66 extern Duple operator/ (Duple const &, double);
67 extern std::ostream & operator<< (std::ostream &, Duple const &);
78 Rect (Coord x0_, Coord y0_, Coord x1_, Coord y1_)
90 boost::optional<Rect> intersection (Rect const &) const;
91 Rect extend (Rect const &) const;
92 Rect translate (Duple) const;
93 Rect expand (Distance) const;
94 bool contains (Duple) const;
97 Rect convert_to_device (Cairo::RefPtr<Cairo::Context>) const;
98 Rect convert_to_user (Cairo::RefPtr<Cairo::Context>) const;
100 Distance width () const {
104 Distance height () const {
109 extern std::ostream & operator<< (std::ostream &, Rect const &);
111 typedef std::vector<Duple> Points;