~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/libnr/nr-scale.h

  • Committer: JazzyNico
  • Date: 2011-08-29 20:25:30 UTC
  • Revision ID: nicoduf@yahoo.fr-20110829202530-6deuoz11q90usldv
Code refactoring and merging with trunk (revision 10599).

Show diffs side-by-side

added added

removed removed

Lines of Context:
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>
5
 
 
6
 
namespace NR {
7
 
 
8
 
class scale {
9
 
private:
10
 
    Point _p;
11
 
 
12
 
private:
13
 
    scale();
14
 
 
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]; }
23
 
 
24
 
    bool operator==(scale const &o) const {
25
 
        return _p == o._p;
26
 
    }
27
 
 
28
 
    bool operator!=(scale const &o) const {
29
 
        return _p != o._p;
30
 
    }
31
 
    
32
 
    scale inverse() const {
33
 
        return scale(1/_p[0], 1/_p[1]);
34
 
    }
35
 
    
36
 
    NR::Point point() const {
37
 
        return _p;    
38
 
    }
39
 
};
40
 
 
41
 
} /* namespace NR */
42
 
 
43
 
 
44
 
#endif /* !SEEN_NR_SCALE_H */
45
 
 
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:encoding=utf-8:textwidth=99 :