|
|
|
@ -1523,11 +1523,13 @@ function PaintWeb (win, doc) {
|
|
|
|
|
* not.
|
|
|
|
|
*/
|
|
|
|
|
this.imageCrop = function (cropX, cropY, cropWidth, cropHeight) {
|
|
|
|
|
var bufferCanvas = this.buffer.canvas,
|
|
|
|
|
bufferContext = this.buffer.context,
|
|
|
|
|
image = this.image,
|
|
|
|
|
layerCanvas = this.layer.canvas,
|
|
|
|
|
layerContext = this.layer.context;
|
|
|
|
|
var orginlCanvas = this.orginl.canvas;
|
|
|
|
|
var orginlContext = this.orginl.context;
|
|
|
|
|
var bufferCanvas = this.buffer.canvas;
|
|
|
|
|
var bufferContext = this.buffer.context;
|
|
|
|
|
var layerCanvas = this.layer.canvas;
|
|
|
|
|
var layerContext = this.layer.context;
|
|
|
|
|
var image = this.image;
|
|
|
|
|
|
|
|
|
|
cropX = parseInt(cropX);
|
|
|
|
|
cropY = parseInt(cropY);
|
|
|
|
@ -1594,9 +1596,12 @@ function PaintWeb (win, doc) {
|
|
|
|
|
|
|
|
|
|
layerCanvas.width = cropWidth;
|
|
|
|
|
layerCanvas.height = cropHeight;
|
|
|
|
|
orginlCanvas.width = cropWidth;
|
|
|
|
|
orginlCanvas.height = cropHeight;
|
|
|
|
|
|
|
|
|
|
if (layerData && layerContext.putImageData) {
|
|
|
|
|
layerContext.putImageData(layerData, 0, 0);
|
|
|
|
|
orginlContext.putImageData(layerData, 0, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.stateRestore(layerContext, layerState);
|
|
|
|
@ -1852,7 +1857,7 @@ function PaintWeb (win, doc) {
|
|
|
|
|
this.historyReset = function () {
|
|
|
|
|
this.history.pos = 0;
|
|
|
|
|
this.history.states = [];
|
|
|
|
|
|
|
|
|
|
this.brightnessSliderValue = 0;
|
|
|
|
|
this.events.dispatch(new appEvent.historyUpdate(0, 0, 0));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -2491,39 +2496,44 @@ function PaintWeb (win, doc) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.imageRotate = function(clockwise){
|
|
|
|
|
var layerCanvas = _self.layer.canvas,
|
|
|
|
|
layerCtx = _self.layer.context,
|
|
|
|
|
bufferCanvas = _self.buffer.canvas,
|
|
|
|
|
bufferCtx = _self.buffer.context,
|
|
|
|
|
img = _self.image;
|
|
|
|
|
var orginlCanvas = _self.orginl.canvas;
|
|
|
|
|
var orginlCtx = _self.orginl.context;
|
|
|
|
|
|
|
|
|
|
var bufferStyle = _self.buffer.canvas.style;
|
|
|
|
|
var layerCanvas = _self.layer.canvas;
|
|
|
|
|
var layerCtx = _self.layer.context;
|
|
|
|
|
var layerStyle = layerCanvas.style;
|
|
|
|
|
|
|
|
|
|
var srcCanvas = doc.createElement('canvas');
|
|
|
|
|
var srcCtx=srcCanvas.getContext("2d");
|
|
|
|
|
var bufferCanvas = _self.buffer.canvas;
|
|
|
|
|
var bufferStyle = _self.buffer.canvas.style;
|
|
|
|
|
var bufferCtx = _self.buffer.context;
|
|
|
|
|
|
|
|
|
|
var img = _self.image;
|
|
|
|
|
|
|
|
|
|
var newCanvas = doc.createElement('canvas');
|
|
|
|
|
var newCtx = newCanvas.getContext("2d");
|
|
|
|
|
|
|
|
|
|
srcCanvas.height = layerCanvas.width;
|
|
|
|
|
srcCanvas.width = layerCanvas.height;
|
|
|
|
|
srcCtx.translate(layerCanvas.height/2,layerCanvas.width/2);
|
|
|
|
|
newCanvas.height = layerCanvas.width;
|
|
|
|
|
newCanvas.width = layerCanvas.height;
|
|
|
|
|
newCtx.translate(layerCanvas.height/2,layerCanvas.width/2);
|
|
|
|
|
if(clockwise){
|
|
|
|
|
srcCtx.rotate(90*Math.PI/180);
|
|
|
|
|
newCtx.rotate(90*Math.PI/180);
|
|
|
|
|
} else {
|
|
|
|
|
srcCtx.rotate(-90*Math.PI/180);
|
|
|
|
|
newCtx.rotate(-90*Math.PI/180);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
srcCtx.drawImage(layerCanvas,-layerCanvas.width/2,-layerCanvas.height/2);
|
|
|
|
|
newCtx.drawImage(layerCanvas,-layerCanvas.width/2,-layerCanvas.height/2);
|
|
|
|
|
|
|
|
|
|
var lineWidth = bufferCtx.lineWidth;
|
|
|
|
|
var strokeStyle = bufferCtx.strokeStyle;
|
|
|
|
|
var fillStyle = bufferCtx.fillStyle;
|
|
|
|
|
layerCanvas.width = bufferCanvas.width = srcCanvas.width;
|
|
|
|
|
layerCanvas.height = bufferCanvas.height = srcCanvas.height;
|
|
|
|
|
bufferCtx.lineWidth = layerCtx.lineWidth = lineWidth;
|
|
|
|
|
bufferCtx.strokeStyle = layerCtx.strokeStyle = strokeStyle;
|
|
|
|
|
bufferCtx.fillStyle = layerCtx.fillStyle = fillStyle;
|
|
|
|
|
orginlCanvas.width = layerCanvas.width = bufferCanvas.width = newCanvas.width;
|
|
|
|
|
orginlCanvas.height = layerCanvas.height = bufferCanvas.height = newCanvas.height;
|
|
|
|
|
orginlCtx.lineWidth = bufferCtx.lineWidth = layerCtx.lineWidth = lineWidth;
|
|
|
|
|
orginlCtx.strokeStyle = bufferCtx.strokeStyle = layerCtx.strokeStyle = strokeStyle;
|
|
|
|
|
orginlCtx.fillStyle = bufferCtx.fillStyle = layerCtx.fillStyle = fillStyle;
|
|
|
|
|
|
|
|
|
|
layerCtx.drawImage(srcCanvas, 0, 0);
|
|
|
|
|
layerCtx.drawImage(newCanvas, 0, 0);
|
|
|
|
|
orginlCtx.drawImage(newCanvas, 0, 0);
|
|
|
|
|
|
|
|
|
|
img.width = layerCanvas.width;
|
|
|
|
|
img.height = layerCanvas.height;
|
|
|
|
@ -2535,8 +2545,7 @@ function PaintWeb (win, doc) {
|
|
|
|
|
|
|
|
|
|
pw.image.modified = true;
|
|
|
|
|
|
|
|
|
|
pw.history.pos = 0;
|
|
|
|
|
pw.history.states = [];
|
|
|
|
|
pw.historyReset();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|