|
362 | 362 | }
|
363 | 363 | if (scale === 1) {
|
364 | 364 | this.pdf.text(text, x, this._getBaseline(y), {
|
365 |
| - stroke: true |
366 |
| - }, degs); |
| 365 | + stroke: true |
| 366 | + }, degs); |
367 | 367 | }
|
368 | 368 | else {
|
369 | 369 | var oldSize = this.pdf.internal.getFontSize();
|
|
1143 | 1143 | moves[moves.length - 1].deltas.push(delta);
|
1144 | 1144 | break;
|
1145 | 1145 | case 'arc':
|
1146 |
| - //TODO this was hack to avoid out-of-bounds issue |
| 1146 | + //TODO this was hack to avoid out-of-bounds issue when drawing circle |
1147 | 1147 | // No move-to before drawing the arc
|
1148 |
| - if (moves.length == 0) { |
1149 |
| - moves.push({start: {x: 0, y: 0}, deltas: [], abs: []}); |
| 1148 | + if (moves.length === 0) { |
| 1149 | + moves.push({deltas: [], abs: []}); |
1150 | 1150 | }
|
1151 | 1151 | moves[moves.length - 1].arc = true;
|
1152 | 1152 | moves[moves.length - 1].abs.push(pt);
|
1153 | 1153 | break;
|
1154 | 1154 | case 'close':
|
1155 |
| - //moves[moves.length - 1].deltas.push('close'); |
| 1155 | + moves.push({close: true}); |
1156 | 1156 | break;
|
1157 | 1157 | }
|
1158 | 1158 | }
|
|
1168 | 1168 | style = null;
|
1169 | 1169 | }
|
1170 | 1170 |
|
1171 |
| - if (moves[i].arc) { |
| 1171 | + if (moves[i].close) { |
| 1172 | + this.pdf.internal.out('h'); |
| 1173 | + this.pdf.internal.out('f'); |
| 1174 | + } |
| 1175 | + else if (moves[i].arc) { |
| 1176 | + if (moves[i].start) { |
| 1177 | + this.internal.move2(this, moves[i].start.x, moves[i].start.y); |
| 1178 | + } |
1172 | 1179 | var arcs = moves[i].abs;
|
1173 | 1180 | for (var ii = 0; ii < arcs.length; ii++) {
|
1174 | 1181 | var arc = arcs[ii];
|
1175 | 1182 | //TODO lines deltas were getting in here
|
1176 | 1183 | if (typeof arc.startAngle !== 'undefined') {
|
1177 | 1184 | var start = arc.startAngle * 360 / (2 * Math.PI);
|
1178 | 1185 | var end = arc.endAngle * 360 / (2 * Math.PI);
|
1179 |
| - // Add the current position (last move to) |
1180 |
| - //var x = moves[i].start.x + arc.x; |
1181 |
| - //var y = moves[i].start.y + arc.y; |
1182 | 1186 | var x = arc.x;
|
1183 | 1187 | var y = arc.y;
|
1184 |
| - if (ii == 0) { |
| 1188 | + if (ii === 0) { |
1185 | 1189 | this.internal.move2(this, x, y);
|
1186 | 1190 | }
|
1187 | 1191 | this.internal.arc2(this, x, y, arc.radius, start, end, arc.anticlockwise, null, isClip);
|
| 1192 | + if (ii === arcs.length - 1) { |
| 1193 | + // The original arc move did not occur because of the algorithm |
| 1194 | + if (moves[i].start) { |
| 1195 | + var x = moves[i].start.x; |
| 1196 | + var y = moves[i].start.y; |
| 1197 | + this.internal.line2(c2d, x, y); |
| 1198 | + } |
| 1199 | + } |
1188 | 1200 | } else {
|
1189 | 1201 | this.internal.line2(c2d, arc.x, arc.y);
|
1190 | 1202 | }
|
1191 | 1203 | }
|
1192 |
| - |
1193 |
| - if (this.pdf.hotfix && this.pdf.hotfix.fill_close) { |
1194 |
| - // do nothing |
1195 |
| - } |
1196 |
| - else { |
1197 |
| - // extra move bug causing close to resolve to wrong point |
1198 |
| - var x = moves[i].start.x; |
1199 |
| - var y = moves[i].start.y; |
1200 |
| - this.internal.line2(c2d, x, y); |
1201 |
| - } |
1202 |
| - |
1203 |
| - this.pdf.internal.out('h'); |
1204 |
| - this.pdf.internal.out('f'); |
1205 | 1204 | }
|
1206 | 1205 | else {
|
1207 | 1206 | var x = moves[i].start.x;
|
|
1422 | 1421 |
|
1423 | 1422 | for (var i = 0; i < curves.length; i++) {
|
1424 | 1423 | var curve = curves[i];
|
1425 |
| - if (includeMove && i == 0) { |
| 1424 | + if (includeMove && i === 0) { |
1426 | 1425 | this.pdf.internal.out([
|
1427 | 1426 | f2((curve.x1 + xc) * k), f2((pageHeight - (curve.y1 + yc)) * k), 'm', f2((curve.x2 + xc) * k), f2((pageHeight - (curve.y2 + yc)) * k), f2((curve.x3 + xc) * k), f2((pageHeight - (curve.y3 + yc)) * k), f2((curve.x4 + xc) * k), f2((pageHeight - (curve.y4 + yc)) * k), 'c'
|
1428 | 1427 | ].join(' '));
|
|
1552 | 1551 | if (startAngleN < 0) {
|
1553 | 1552 | startAngleN = twoPI + startAngleN;
|
1554 | 1553 | }
|
1555 |
| - |
| 1554 | + |
1556 | 1555 | while (startAngle > endAngle) {
|
1557 | 1556 | startAngle = startAngle - twoPI;
|
1558 | 1557 | }
|
|
0 commit comments