1 #ifndef SEEN_NR_SCALE_H
2 #define SEEN_NR_SCALE_H
3 #include <libnr/nr-point.h>
4 #include <libnr/nr-point-ops.h>
6 namespace NR {
8 class scale {
9 private:
10 Point _p;
12 private:
13 scale();
15 public:
16 explicit scale(Point const &p) : _p(p) {}
17 scale(double const x, double const y) : _p(x, y) {}
18 explicit scale(double const s) : _p(s, s) {}
19 inline Coord operator[](Dim2 const d) const { return _p[d]; }
20 inline Coord operator[](unsigned const d) const { return _p[d]; }
21 inline Coord &operator[](Dim2 const d) { return _p[d]; }
22 inline Coord &operator[](unsigned const d) { return _p[d]; }
24 bool operator==(scale const &o) const {
25 return _p == o._p;
26 }
28 bool operator!=(scale const &o) const {
29 return _p != o._p;
30 }
32 scale inverse() const {
33 return scale(1/_p[0], 1/_p[1]);
34 }
36 NR::Point point() const {
37 return _p;
38 }
39 };
41 } /* namespace NR */
44 #endif /* !SEEN_NR_SCALE_H */
46 /*
47 Local Variables:
48 mode:c++
49 c-file-style:"stroustrup"
50 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
51 indent-tabs-mode:nil
52 fill-column:99
53 End:
54 */
55 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :