Implement J (line-cap style)
This commit is contained in:
parent
a8d9ab5e62
commit
5bf0818b2e
33
pdf.js
33
pdf.js
@ -1000,6 +1000,7 @@ var Interpreter = (function() {
|
|||||||
this.map = {
|
this.map = {
|
||||||
// Graphics state
|
// Graphics state
|
||||||
w: gfx.setLineWidth,
|
w: gfx.setLineWidth,
|
||||||
|
J: gfx.setLineCap,
|
||||||
d: gfx.setDash,
|
d: gfx.setDash,
|
||||||
q: gfx.save,
|
q: gfx.save,
|
||||||
Q: gfx.restore,
|
Q: gfx.restore,
|
||||||
@ -1105,6 +1106,9 @@ var EchoGraphics = (function() {
|
|||||||
setLineWidth: function(width) {
|
setLineWidth: function(width) {
|
||||||
this.printdentln(width +" w");
|
this.printdentln(width +" w");
|
||||||
},
|
},
|
||||||
|
setLineCap: function(style) {
|
||||||
|
this.printdentln(style +" J");
|
||||||
|
},
|
||||||
setDash: function(dashArray, dashPhase) {
|
setDash: function(dashArray, dashPhase) {
|
||||||
this.printdentln(""+ dashArray +" "+ dashPhase +" d");
|
this.printdentln(""+ dashArray +" "+ dashPhase +" d");
|
||||||
},
|
},
|
||||||
@ -1242,6 +1246,8 @@ var CanvasGraphics = (function() {
|
|||||||
this.stateStack = [ ];
|
this.stateStack = [ ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var LINE_CAP_STYLES = [ "butt", "round", "square" ];
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
beginDrawing: function(mediaBox) {
|
beginDrawing: function(mediaBox) {
|
||||||
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
|
var cw = this.ctx.canvas.width, ch = this.ctx.canvas.height;
|
||||||
@ -1257,6 +1263,9 @@ var CanvasGraphics = (function() {
|
|||||||
setLineWidth: function(width) {
|
setLineWidth: function(width) {
|
||||||
this.ctx.lineWidth = width;
|
this.ctx.lineWidth = width;
|
||||||
},
|
},
|
||||||
|
setLineCap: function(style) {
|
||||||
|
this.ctx.lineCap = LINE_CAP_STYLES[style];
|
||||||
|
},
|
||||||
setDash: function(dashArray, dashPhase) {
|
setDash: function(dashArray, dashPhase) {
|
||||||
// TODO
|
// TODO
|
||||||
},
|
},
|
||||||
@ -1511,6 +1520,30 @@ var tests = [
|
|||||||
eof()
|
eof()
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{ name: "Line cap",
|
||||||
|
res: { },
|
||||||
|
mediaBox: [ 0, 0, 612, 792 ],
|
||||||
|
objs: [
|
||||||
|
int(5), cmd("w"),
|
||||||
|
|
||||||
|
int(0), cmd("J"), // butt cap
|
||||||
|
int(100), int(692), cmd("m"),
|
||||||
|
int(200), int(692), cmd("l"),
|
||||||
|
cmd("S"),
|
||||||
|
|
||||||
|
int(1), cmd("J"), // round cap
|
||||||
|
int(100), int(686), cmd("m"),
|
||||||
|
int(200), int(686), cmd("l"),
|
||||||
|
cmd("S"),
|
||||||
|
|
||||||
|
int(2), cmd("J"), // projecting square cap
|
||||||
|
int(100), int(680), cmd("m"),
|
||||||
|
int(200), int(680), cmd("l"),
|
||||||
|
cmd("S"),
|
||||||
|
|
||||||
|
eof()
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user