implement even-odd fill/clip
This commit is contained in:
parent
92aa46cf81
commit
2f8d80677b
21
pdf.js
21
pdf.js
@ -2229,8 +2229,9 @@ var CanvasGraphics = (function() {
|
|||||||
this.consumePath();
|
this.consumePath();
|
||||||
},
|
},
|
||||||
eoFill: function() {
|
eoFill: function() {
|
||||||
TODO("even-odd fill");
|
var savedFillRule = this.setEOFillRule();
|
||||||
this.fill();
|
this.fill();
|
||||||
|
this.restoreFillRule(savedFillRule);
|
||||||
},
|
},
|
||||||
fillStroke: function() {
|
fillStroke: function() {
|
||||||
this.ctx.fill();
|
this.ctx.fill();
|
||||||
@ -2434,10 +2435,15 @@ var CanvasGraphics = (function() {
|
|||||||
|
|
||||||
consumePath: function() {
|
consumePath: function() {
|
||||||
if (this.pendingClip) {
|
if (this.pendingClip) {
|
||||||
|
var savedFillRule = null;
|
||||||
if (this.pendingClip == EO_CLIP)
|
if (this.pendingClip == EO_CLIP)
|
||||||
TODO("even-odd clipping");
|
savedFillRule = this.setEOFillRule();
|
||||||
|
|
||||||
this.ctx.clip();
|
this.ctx.clip();
|
||||||
|
|
||||||
this.pendingClip = null;
|
this.pendingClip = null;
|
||||||
|
if (savedFillRule !== null)
|
||||||
|
this.restoreFillRule(savedFillRule);
|
||||||
}
|
}
|
||||||
this.ctx.beginPath();
|
this.ctx.beginPath();
|
||||||
},
|
},
|
||||||
@ -2445,6 +2451,17 @@ var CanvasGraphics = (function() {
|
|||||||
var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0;
|
var ri = (255 * r) | 0, gi = (255 * g) | 0, bi = (255 * b) | 0;
|
||||||
return "rgb("+ ri +","+ gi +","+ bi +")";
|
return "rgb("+ ri +","+ gi +","+ bi +")";
|
||||||
},
|
},
|
||||||
|
// We generally keep the canvas context set for
|
||||||
|
// nonzero-winding, and just set evenodd for the operations
|
||||||
|
// that need them.
|
||||||
|
setEOFillRule: function() {
|
||||||
|
var savedFillRule = this.ctx.mozFillRule;
|
||||||
|
this.ctx.mozFillRule = "evenodd";
|
||||||
|
return savedFillRule;
|
||||||
|
},
|
||||||
|
restoreFillRule: function(rule) {
|
||||||
|
this.ctx.mozFillRule = rule;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return constructor;
|
return constructor;
|
||||||
|
@ -40,7 +40,7 @@ function load() {
|
|||||||
canvas.mozOpaque = true;
|
canvas.mozOpaque = true;
|
||||||
pageDisplay = document.getElementById("pageNumber");
|
pageDisplay = document.getElementById("pageNumber");
|
||||||
infoDisplay = document.getElementById("info");
|
infoDisplay = document.getElementById("info");
|
||||||
open("compressed.tracemonkey-pldi-09.pdf");
|
open("uncompressed.tracemonkey-pldi-09.pdf");
|
||||||
}
|
}
|
||||||
|
|
||||||
function open(url) {
|
function open(url) {
|
||||||
|
Loading…
Reference in New Issue
Block a user