| @@ 7685-7764 (lines=80) @@ | ||
| 7682 | this.current.dashPhase = dashPhase; |
|
| 7683 | }, |
|
| 7684 | ||
| 7685 | constructPath: function SVGGraphics_constructPath(ops, args) { |
|
| 7686 | var current = this.current; |
|
| 7687 | var x = current.x, y = current.y; |
|
| 7688 | current.path = document.createElementNS(NS, 'svg:path'); |
|
| 7689 | var d = []; |
|
| 7690 | var opLength = ops.length; |
|
| 7691 | ||
| 7692 | for (var i = 0, j = 0; i < opLength; i++) { |
|
| 7693 | switch (ops[i] | 0) { |
|
| 7694 | case OPS.rectangle: |
|
| 7695 | x = args[j++]; |
|
| 7696 | y = args[j++]; |
|
| 7697 | var width = args[j++]; |
|
| 7698 | var height = args[j++]; |
|
| 7699 | var xw = x + width; |
|
| 7700 | var yh = y + height; |
|
| 7701 | d.push('M', pf(x), pf(y), 'L', pf(xw) , pf(y), 'L', pf(xw), pf(yh), |
|
| 7702 | 'L', pf(x), pf(yh), 'Z'); |
|
| 7703 | break; |
|
| 7704 | case OPS.moveTo: |
|
| 7705 | x = args[j++]; |
|
| 7706 | y = args[j++]; |
|
| 7707 | d.push('M', pf(x), pf(y)); |
|
| 7708 | break; |
|
| 7709 | case OPS.lineTo: |
|
| 7710 | x = args[j++]; |
|
| 7711 | y = args[j++]; |
|
| 7712 | d.push('L', pf(x) , pf(y)); |
|
| 7713 | break; |
|
| 7714 | case OPS.curveTo: |
|
| 7715 | x = args[j + 4]; |
|
| 7716 | y = args[j + 5]; |
|
| 7717 | d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), |
|
| 7718 | pf(args[j + 3]), pf(x), pf(y)); |
|
| 7719 | j += 6; |
|
| 7720 | break; |
|
| 7721 | case OPS.curveTo2: |
|
| 7722 | x = args[j + 2]; |
|
| 7723 | y = args[j + 3]; |
|
| 7724 | d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), |
|
| 7725 | pf(args[j + 2]), pf(args[j + 3])); |
|
| 7726 | j += 4; |
|
| 7727 | break; |
|
| 7728 | case OPS.curveTo3: |
|
| 7729 | x = args[j + 2]; |
|
| 7730 | y = args[j + 3]; |
|
| 7731 | d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), |
|
| 7732 | pf(x), pf(y)); |
|
| 7733 | j += 4; |
|
| 7734 | break; |
|
| 7735 | case OPS.closePath: |
|
| 7736 | d.push('Z'); |
|
| 7737 | break; |
|
| 7738 | } |
|
| 7739 | } |
|
| 7740 | current.path.setAttributeNS(null, 'd', d.join(' ')); |
|
| 7741 | current.path.setAttributeNS(null, 'stroke-miterlimit', |
|
| 7742 | pf(current.miterLimit)); |
|
| 7743 | current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap); |
|
| 7744 | current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); |
|
| 7745 | current.path.setAttributeNS(null, 'stroke-width', |
|
| 7746 | pf(current.lineWidth) + 'px'); |
|
| 7747 | current.path.setAttributeNS(null, 'stroke-dasharray', |
|
| 7748 | current.dashArray.map(pf).join(' ')); |
|
| 7749 | current.path.setAttributeNS(null, 'stroke-dashoffset', |
|
| 7750 | pf(current.dashPhase) + 'px'); |
|
| 7751 | current.path.setAttributeNS(null, 'fill', 'none'); |
|
| 7752 | ||
| 7753 | this.tgrp.appendChild(current.path); |
|
| 7754 | if (current.pendingClip) { |
|
| 7755 | this.cgrp.appendChild(this.tgrp); |
|
| 7756 | this.pgrp.appendChild(this.cgrp); |
|
| 7757 | } else { |
|
| 7758 | this.pgrp.appendChild(this.tgrp); |
|
| 7759 | } |
|
| 7760 | // Saving a reference in current.element so that it can be addressed |
|
| 7761 | // in 'fill' and 'stroke' |
|
| 7762 | current.element = current.path; |
|
| 7763 | current.setCurrentPoint(x, y); |
|
| 7764 | }, |
|
| 7765 | ||
| 7766 | endPath: function SVGGraphics_endPath() { |
|
| 7767 | var current = this.current; |
|
| @@ 4286-4348 (lines=63) @@ | ||
| 4283 | }, |
|
| 4284 | ||
| 4285 | // Path |
|
| 4286 | constructPath: function CanvasGraphics_constructPath(ops, args) { |
|
| 4287 | var ctx = this.ctx; |
|
| 4288 | var current = this.current; |
|
| 4289 | var x = current.x, y = current.y; |
|
| 4290 | for (var i = 0, j = 0, ii = ops.length; i < ii; i++) { |
|
| 4291 | switch (ops[i] | 0) { |
|
| 4292 | case OPS.rectangle: |
|
| 4293 | x = args[j++]; |
|
| 4294 | y = args[j++]; |
|
| 4295 | var width = args[j++]; |
|
| 4296 | var height = args[j++]; |
|
| 4297 | if (width === 0) { |
|
| 4298 | width = this.getSinglePixelWidth(); |
|
| 4299 | } |
|
| 4300 | if (height === 0) { |
|
| 4301 | height = this.getSinglePixelWidth(); |
|
| 4302 | } |
|
| 4303 | var xw = x + width; |
|
| 4304 | var yh = y + height; |
|
| 4305 | this.ctx.moveTo(x, y); |
|
| 4306 | this.ctx.lineTo(xw, y); |
|
| 4307 | this.ctx.lineTo(xw, yh); |
|
| 4308 | this.ctx.lineTo(x, yh); |
|
| 4309 | this.ctx.lineTo(x, y); |
|
| 4310 | this.ctx.closePath(); |
|
| 4311 | break; |
|
| 4312 | case OPS.moveTo: |
|
| 4313 | x = args[j++]; |
|
| 4314 | y = args[j++]; |
|
| 4315 | ctx.moveTo(x, y); |
|
| 4316 | break; |
|
| 4317 | case OPS.lineTo: |
|
| 4318 | x = args[j++]; |
|
| 4319 | y = args[j++]; |
|
| 4320 | ctx.lineTo(x, y); |
|
| 4321 | break; |
|
| 4322 | case OPS.curveTo: |
|
| 4323 | x = args[j + 4]; |
|
| 4324 | y = args[j + 5]; |
|
| 4325 | ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], |
|
| 4326 | x, y); |
|
| 4327 | j += 6; |
|
| 4328 | break; |
|
| 4329 | case OPS.curveTo2: |
|
| 4330 | ctx.bezierCurveTo(x, y, args[j], args[j + 1], |
|
| 4331 | args[j + 2], args[j + 3]); |
|
| 4332 | x = args[j + 2]; |
|
| 4333 | y = args[j + 3]; |
|
| 4334 | j += 4; |
|
| 4335 | break; |
|
| 4336 | case OPS.curveTo3: |
|
| 4337 | x = args[j + 2]; |
|
| 4338 | y = args[j + 3]; |
|
| 4339 | ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y); |
|
| 4340 | j += 4; |
|
| 4341 | break; |
|
| 4342 | case OPS.closePath: |
|
| 4343 | ctx.closePath(); |
|
| 4344 | break; |
|
| 4345 | } |
|
| 4346 | } |
|
| 4347 | current.setCurrentPoint(x, y); |
|
| 4348 | }, |
|
| 4349 | closePath: function CanvasGraphics_closePath() { |
|
| 4350 | this.ctx.closePath(); |
|
| 4351 | }, |
|