|
64 | 64 | this.pdf.rect(xRect.x, xRect.y, xRect.w, xRect.h, "s");
|
65 | 65 | },
|
66 | 66 |
|
| 67 | + /** |
| 68 | + * We cannot clear PDF commands that were already written to PDF, so we use white instead. <br /> |
| 69 | + * As a special case, read a special flag (_ignoreClearRect) and do nothing if it is set. |
| 70 | + * This allows an calls to clearRect() to keep the canvas transparent. |
| 71 | + * This flag is stored in the save/restore context can managed in the same way as other drawing states. |
| 72 | + * @param x |
| 73 | + * @param y |
| 74 | + * @param w |
| 75 | + * @param h |
| 76 | + */ |
67 | 77 | clearRect: function (x, y, w, h) {
|
| 78 | + if (this.ctx.ignoreClearRect) { |
| 79 | + return; |
| 80 | + } |
| 81 | + |
68 | 82 | x = this._wrapX(x);
|
69 | 83 | y = this._wrapY(y);
|
70 | 84 |
|
|
1159 | 1173 | pushMask: function () {
|
1160 | 1174 | var v2Support = typeof this.pdf.internal.newObject2 === 'function';
|
1161 | 1175 |
|
1162 |
| - if (!v2Support){ |
| 1176 | + if (!v2Support) { |
1163 | 1177 | console.log('jsPDF v2 not enabled')
|
1164 | 1178 | return;
|
1165 | 1179 | }
|
|
1322 | 1336 | return this.ctx.globalAlpha;
|
1323 | 1337 | }
|
1324 | 1338 | });
|
| 1339 | + // Not HTML API |
| 1340 | + Object.defineProperty(c2d, 'ignoreClearRect', { |
| 1341 | + set: function (value) { |
| 1342 | + this.ctx.ignoreClearRect = value; |
| 1343 | + }, |
| 1344 | + get: function () { |
| 1345 | + return this.ctx.ignoreClearRect; |
| 1346 | + } |
| 1347 | + }); |
| 1348 | + // End Not HTML API |
1325 | 1349 |
|
1326 | 1350 | c2d.internal = {};
|
1327 | 1351 |
|
|
1560 | 1584 | this._clip_path = [];
|
1561 | 1585 | // TODO miter limit //default 10
|
1562 | 1586 |
|
| 1587 | + // Not HTML API |
| 1588 | + this.ignoreClearRect = false; |
| 1589 | + |
1563 | 1590 | this.copy = function (ctx) {
|
1564 | 1591 | this._isStrokeTransparent = ctx._isStrokeTransparent;
|
1565 | 1592 | this._strokeOpacity = ctx._strokeOpacity;
|
|
1578 | 1605 | this.globalCompositeOperation = ctx.globalCompositeOperation;
|
1579 | 1606 | this.globalAlpha = ctx.globalAlpha;
|
1580 | 1607 | this._clip_path = ctx._clip_path.slice(0); //TODO deep copy?
|
| 1608 | + |
| 1609 | + // Not HTML API |
| 1610 | + this.ignoreClearRect = ctx.ignoreClearRect; |
1581 | 1611 | };
|
1582 | 1612 | }
|
1583 | 1613 |
|
|
0 commit comments