mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 10:15:37 +02:00
Merge pull request #4683 from yurydelendik/grouppath
Groups path commands into single operation
This commit is contained in:
commit
a26d28a393
4 changed files with 68 additions and 24 deletions
|
@ -968,26 +968,49 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||
},
|
||||
|
||||
// Path
|
||||
moveTo: function CanvasGraphics_moveTo(x, y) {
|
||||
this.ctx.moveTo(x, y);
|
||||
this.current.setCurrentPoint(x, y);
|
||||
},
|
||||
lineTo: function CanvasGraphics_lineTo(x, y) {
|
||||
this.ctx.lineTo(x, y);
|
||||
this.current.setCurrentPoint(x, y);
|
||||
},
|
||||
curveTo: function CanvasGraphics_curveTo(x1, y1, x2, y2, x3, y3) {
|
||||
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
|
||||
this.current.setCurrentPoint(x3, y3);
|
||||
},
|
||||
curveTo2: function CanvasGraphics_curveTo2(x2, y2, x3, y3) {
|
||||
constructPath: function CanvasGraphics_constructPath(ops, args) {
|
||||
var ctx = this.ctx;
|
||||
var current = this.current;
|
||||
this.ctx.bezierCurveTo(current.x, current.y, x2, y2, x3, y3);
|
||||
current.setCurrentPoint(x3, y3);
|
||||
},
|
||||
curveTo3: function CanvasGraphics_curveTo3(x1, y1, x3, y3) {
|
||||
this.curveTo(x1, y1, x3, y3, x3, y3);
|
||||
this.current.setCurrentPoint(x3, y3);
|
||||
var x = current.x, y = current.y;
|
||||
for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
|
||||
switch (ops[i] | 0) {
|
||||
case OPS.moveTo:
|
||||
x = args[j++];
|
||||
y = args[j++];
|
||||
ctx.moveTo(x, y);
|
||||
break;
|
||||
case OPS.lineTo:
|
||||
x = args[j++];
|
||||
y = args[j++];
|
||||
ctx.lineTo(x, y);
|
||||
break;
|
||||
case OPS.curveTo:
|
||||
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
|
||||
args[j + 4], args[j + 5]);
|
||||
x = args[j + 4];
|
||||
y = args[j + 5];
|
||||
j += 6;
|
||||
break;
|
||||
case OPS.curveTo2:
|
||||
ctx.bezierCurveTo(x, y, args[j], args[j + 1],
|
||||
args[j + 2], args[j + 3]);
|
||||
x = args[j + 2];
|
||||
y = args[j + 3];
|
||||
j += 4;
|
||||
break;
|
||||
case OPS.curveTo3:
|
||||
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3],
|
||||
args[j + 2], args[j + 3]);
|
||||
x = args[j + 2];
|
||||
y = args[j + 3];
|
||||
j += 4;
|
||||
break;
|
||||
case OPS.closePath:
|
||||
ctx.closePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
current.setCurrentPoint(x, y);
|
||||
},
|
||||
closePath: function CanvasGraphics_closePath() {
|
||||
this.ctx.closePath();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue