mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
created tool class which keeps track of cursors, incorporates changeTool; made changelog data its own file
This commit is contained in:
@ -3,14 +3,14 @@ function changeZoom (layer, direction, cursorLocation) {
|
||||
var oldWidth = canvasSize[0] * zoom;
|
||||
var oldHeight = canvasSize[1] * zoom;
|
||||
var newWidth, newHeight;
|
||||
|
||||
|
||||
//change zoom level
|
||||
//if you want to zoom out, and the zoom isnt already at the smallest level
|
||||
if (direction == 'out' && zoom > 1) {
|
||||
zoom -= Math.ceil(zoom / 10);
|
||||
newWidth = canvasSize[0] * zoom;
|
||||
newHeight = canvasSize[1] * zoom;
|
||||
|
||||
|
||||
//adjust canvas position
|
||||
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft + (oldWidth - newWidth) *cursorLocation[0]/oldWidth, layer.canvas.offsetTop + (oldHeight - newHeight) *cursorLocation[1]/oldWidth)
|
||||
}
|
||||
@ -19,14 +19,14 @@ function changeZoom (layer, direction, cursorLocation) {
|
||||
zoom += Math.ceil(zoom/10);
|
||||
newWidth = canvasSize[0] * zoom;
|
||||
newHeight = canvasSize[1] * zoom;
|
||||
|
||||
|
||||
//adjust canvas position
|
||||
setCanvasOffset(layer.canvas, layer.canvas.offsetLeft - Math.round((newWidth - oldWidth)*cursorLocation[0]/oldWidth), layer.canvas.offsetTop - Math.round((newHeight - oldHeight)*cursorLocation[1]/oldHeight))
|
||||
}
|
||||
|
||||
|
||||
//resize canvas
|
||||
layer.resize();
|
||||
|
||||
// adjust brush size
|
||||
updateCursor();
|
||||
currentTool.updateCursor();
|
||||
}
|
Reference in New Issue
Block a user