Move getting the Pattern from IR form out and make setStrokeColorN_IR work

This commit is contained in:
Julian Viereck 2011-09-07 13:38:52 -07:00
parent 9e3de8b339
commit 5543d6f448

59
pdf.js
View File

@ -4222,7 +4222,8 @@ var PartialEvaluator = (function() {
// TODO figure out how to type-check vararg functions
if ((cmd == 'SCN' || cmd == 'scn') && !args[args.length - 1].code) {
fn = "setFillColorN_IR";
// Use the IR version for setStroke/FillColorN.
fn += '_IR';
// compile tiling patterns
var patternName = args[args.length - 1];
@ -5276,28 +5277,7 @@ var CanvasGraphics = (function() {
this.setStrokeColor.apply(this, arguments);
}
},
setFillColor: function(/*...*/) {
var cs = this.current.fillColorSpace;
var color = cs.getRgb(arguments);
this.setFillRGBColor.apply(this, color);
},
setFillColorN: function(/*...*/) {
var cs = this.current.fillColorSpace;
if (cs.name == 'Pattern') {
// wait until fill to actually get the pattern
var pattern = Pattern.parse(arguments, cs, this.xref, this.res,
this.ctx);
this.current.fillColor = pattern;
} else {
this.setFillColor.apply(this, arguments);
}
},
setFillColorN_IR: function(/*...*/) {
var cs = this.current.fillColorSpace;
if (cs.name == 'Pattern') {
var IR = arguments;
getColorN_IR_Pattern: function(IR) {
if (IR[0] == "TilingPatternIR") {
// First, build the `color` var like it's done in the
// Pattern.prototype.parse function.
@ -5320,11 +5300,44 @@ var CanvasGraphics = (function() {
} else {
throw "Unkown IR type";
}
return pattern;
},
setStrokeColorN_IR: function(/*...*/) {
var cs = this.current.strokeColorSpace;
if (cs.name == 'Pattern') {
this.current.strokeColor = this.getColorN_IR_Pattern(arguments);
} else {
this.setStrokeColor.apply(this, arguments);
}
},
setFillColor: function(/*...*/) {
var cs = this.current.fillColorSpace;
var color = cs.getRgb(arguments);
this.setFillRGBColor.apply(this, color);
},
setFillColorN: function(/*...*/) {
var cs = this.current.fillColorSpace;
if (cs.name == 'Pattern') {
// wait until fill to actually get the pattern
var pattern = Pattern.parse(arguments, cs, this.xref, this.res,
this.ctx);
this.current.fillColor = pattern;
} else {
this.setFillColor.apply(this, arguments);
}
},
setFillColorN_IR: function(/*...*/) {
var cs = this.current.fillColorSpace;
if (cs.name == 'Pattern') {
this.current.fillColor = this.getColorN_IR_Pattern(arguments);
} else {
this.setFillColor.apply(this, arguments);
}
},
setStrokeGray: function(gray) {
this.setStrokeRGBColor(gray, gray, gray);
},