~vaifrax/inkscape/bugfix170049

« back to all changes in this revision

Viewing changes to src/livarot/path-description.cpp

  • Committer: mental
  • Date: 2006-01-16 02:36:01 UTC
  • Revision ID: mental@users.sourceforge.net-20060116023601-wkr0h7edl5veyudq
moving trunk for module inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "libnr/nr-point-matrix-ops.h"
 
2
#include "livarot/path-description.h"
 
3
 
 
4
PathDescr *PathDescrMoveTo::clone() const
 
5
{
 
6
    return new PathDescrMoveTo(*this);
 
7
}
 
8
 
 
9
void PathDescrMoveTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
 
10
{
 
11
    s << "M " << p[NR::X] << " " << p[NR::Y] << " ";
 
12
}
 
13
 
 
14
void PathDescrMoveTo::transform(NR::Matrix const& t)
 
15
{
 
16
    p = p * t;
 
17
}
 
18
 
 
19
void PathDescrMoveTo::dump(std::ostream &s) const
 
20
{
 
21
    /* localizing ok */
 
22
    s << "  m " << p[NR::X] << " " << p[NR::Y];
 
23
}
 
24
 
 
25
void PathDescrLineTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
 
26
{
 
27
    s << "L " << p[NR::X] << " " << p[NR::Y] << " ";
 
28
}
 
29
 
 
30
PathDescr *PathDescrLineTo::clone() const
 
31
{
 
32
    return new PathDescrLineTo(*this);
 
33
}
 
34
 
 
35
void PathDescrLineTo::transform(NR::Matrix const& t)
 
36
{
 
37
    p = p * t;
 
38
}
 
39
 
 
40
void PathDescrLineTo::dump(std::ostream &s) const
 
41
{
 
42
    /* localizing ok */
 
43
    s << "  l " << p[NR::X] << " " << p[NR::Y];
 
44
}
 
45
 
 
46
PathDescr *PathDescrBezierTo::clone() const
 
47
{
 
48
    return new PathDescrBezierTo(*this);
 
49
}
 
50
 
 
51
void PathDescrBezierTo::transform(NR::Matrix const& t)
 
52
{
 
53
    p = p * t;
 
54
}
 
55
 
 
56
void PathDescrBezierTo::dump(std::ostream &s) const
 
57
{
 
58
    /* localizing ok */
 
59
    s << "  b " << p[NR::X] << " " << p[NR::Y] << " " << nb;
 
60
}
 
61
 
 
62
PathDescr *PathDescrIntermBezierTo::clone() const
 
63
{
 
64
    return new PathDescrIntermBezierTo(*this);
 
65
}
 
66
 
 
67
void PathDescrIntermBezierTo::transform(NR::Matrix const& t)
 
68
{
 
69
    p = p * t;
 
70
}
 
71
 
 
72
void PathDescrIntermBezierTo::dump(std::ostream &s) const
 
73
{
 
74
    /* localizing ok */
 
75
    s << "  i " << p[NR::X] << " " << p[NR::Y];
 
76
}
 
77
 
 
78
void PathDescrCubicTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
 
79
{
 
80
    s << "C "
 
81
      << last[NR::X] + start[0] / 3 << " "
 
82
      << last[NR::Y] + start[1] / 3 << " "
 
83
      << p[NR::X] - end[0] / 3 << " "
 
84
      << p[NR::Y] - end[1] / 3 << " "
 
85
      << p[NR::X] << " "
 
86
      << p[NR::Y] << " ";
 
87
}
 
88
 
 
89
PathDescr *PathDescrCubicTo::clone() const
 
90
{
 
91
    return new PathDescrCubicTo(*this);
 
92
}
 
93
 
 
94
void PathDescrCubicTo::dump(std::ostream &s) const
 
95
{
 
96
    /* localizing ok */
 
97
    s << "  c "
 
98
      << p[NR::X] << " " << p[NR::Y] << " "
 
99
      << start[NR::X] << " " << start[NR::Y] << " "
 
100
      << end[NR::X] << " " << end[NR::Y] << " ";
 
101
}
 
102
 
 
103
void PathDescrCubicTo::transform(NR::Matrix const& t)
 
104
{
 
105
    NR::Matrix tr = t;
 
106
    tr[4] = tr[5] = 0;
 
107
    start = start * tr;
 
108
    end = end * tr;
 
109
    
 
110
    p = p * t;
 
111
}
 
112
 
 
113
void PathDescrArcTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
 
114
{
 
115
    s << "A "
 
116
      << rx << " "
 
117
      << ry << " "
 
118
      << angle << " "
 
119
      << (large ? "1" : "0") << " "
 
120
      << (clockwise ? "0" : "1") << " "
 
121
      << p[NR::X] << " "
 
122
      << p[NR::Y] << " ";
 
123
}
 
124
 
 
125
PathDescr *PathDescrArcTo::clone() const
 
126
{
 
127
    return new PathDescrArcTo(*this);
 
128
}
 
129
 
 
130
void PathDescrArcTo::transform(NR::Matrix const& t)
 
131
{
 
132
    p = p * t;
 
133
}
 
134
 
 
135
void PathDescrArcTo::dump(std::ostream &s) const
 
136
{
 
137
    /* localizing ok */
 
138
    s << "  a "
 
139
      << p[NR::X] << " " << p[NR::Y] << " "
 
140
      << rx << " " << ry << " "
 
141
      << angle << " "
 
142
      << (clockwise ? 1 : 0) << " "
 
143
      << (large ? 1 : 0);
 
144
}
 
145
 
 
146
PathDescr *PathDescrForced::clone() const
 
147
{
 
148
    return new PathDescrForced(*this);
 
149
}
 
150
 
 
151
void PathDescrClose::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
 
152
{
 
153
    s << "z ";
 
154
}
 
155
 
 
156
PathDescr *PathDescrClose::clone() const
 
157
{
 
158
    return new PathDescrClose(*this);
 
159
}
 
160
 
 
161
 
 
162
/*
 
163
  Local Variables:
 
164
  mode:c++
 
165
  c-file-style:"stroustrup"
 
166
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
167
  indent-tabs-mode:nil
 
168
  fill-column:99
 
169
  End:
 
170
*/
 
171
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :