=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js 2016-01-29 15:50:34 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js 2016-02-12 09:27:24 +0000 @@ -502,7 +502,7 @@ { // holds the line pixels to draw var path = []; - + x1 = x1 + this.origin.x; x2 = x2 + this.origin.x; @@ -513,16 +513,21 @@ var d = this.cutLine(x1, y1, x2, y2); if (d === null) { - return path; + return {path : path, imageData : null}; } x1 = d[0]; y1 = d[1]; x2 = d[2]; y2 = d[3]; + var dx = Math.abs(x2 - x1); var dy = Math.abs(y2 - y1); - + var width = dx + 1; + var height = dy + 1; + var buffer = new ArrayBuffer(4 * width * height); + var imageData = new Uint8ClampedArray(buffer); + var xIncr = x1 < x2 ? 1 : -1; var yIncr = y1 < y2 ? 1 : -1; @@ -533,7 +538,7 @@ var x = x1; var y = y1; - + var curr = 0; var tooMany = 0; var directStroke = this.strokesManager.isDirectDrawingStrokeStyle(this.strokeStyleId); @@ -541,7 +546,11 @@ { if (directStroke) { - this.drawPixel(x, y, color); + //this.drawPixel(x, y, color); + imageData[curr++] = color[0]; + imageData[curr++] = color[1]; + imageData[curr++] = color[2]; + imageData[curr++] = 255; } path.push({x : x, y : y}); @@ -577,7 +586,7 @@ } } - return path; + return {path : path, imageData : imageData, x1 : x1, y1 : y1, width : width, height : height , draw : directStroke}; }; /** @@ -605,7 +614,13 @@ CanvasRenderer.prototype.drawLine = function(x1, y1, x2, y2, color, path) { var segment = this.drawLineSegment(x1, y1, x2, y2, color); - Array.prototype.push.apply(path, segment); + if (segment.imageData && segment.draw) + { + var img = this.ctx.getImageData(segment.x1, segment.y1, segment.width, segment.height); + img.data.set(segment.imageData, 0); + this.ctx.putImageData(img, segment.x1, segment.y1); + } + Array.prototype.push.apply(path, segment.path); return segment; } @@ -631,12 +646,18 @@ */ CanvasRenderer.prototype.strokeLineSegment = function(x1, y1, x2, y2, color) { - var path = this.drawLineSegment(x1, y1, x2, y2, color); + var segment = this.drawLineSegment(x1, y1, x2, y2, color); + if (segment.imageData && segment.draw) + { + var img = this.ctx.getImageData(segment.x1, segment.y1, segment.width, segment.height); + img.data.set(segment.imageData, 0); + this.ctx.putImageData(img, segment.x1, segment.y1); + } this.strokesManager.applyStrokeToPath(this, this.strokeStyleId, this.strokeWidth, color, - path); + segment.path); } /**