mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Fixed line tool bugs
This commit is contained in:
parent
5556587088
commit
9fc5c8e3b8
@ -1554,6 +1554,8 @@ div#pb-options {
|
|||||||
background-color: #232125 !important;
|
background-color: #232125 !important;
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
|
|
||||||
|
display: none !important;
|
||||||
|
|
||||||
#splash-input {
|
#splash-input {
|
||||||
width:70%;
|
width:70%;
|
||||||
height:100vh !important;
|
height:100vh !important;
|
||||||
|
@ -17,6 +17,7 @@ function diagLine(lastMouseClickPos, zoom, cursorLocation) {
|
|||||||
const context = canvas.getContext('2d');
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
context.fillStyle=currentGlobalColor;
|
context.fillStyle=currentGlobalColor;
|
||||||
|
canvas.style.zIndex = MAX_Z_INDEX;
|
||||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -338,6 +338,21 @@ function draw (mouseEvent) {
|
|||||||
tool.rectangle.moveBrushPreview(lastMouseClickPos);
|
tool.rectangle.moveBrushPreview(lastMouseClickPos);
|
||||||
currentTool.updateCursor();
|
currentTool.updateCursor();
|
||||||
}
|
}
|
||||||
|
else if (currentTool.name == 'resizeline' && dragging) {
|
||||||
|
//get new brush size based on x distance from original clicking location
|
||||||
|
var distanceFromClick = cursorLocation[0] - lastMouseClickPos[0];
|
||||||
|
//var roundingAmount = 20 - Math.round(distanceFromClick/10);
|
||||||
|
//this doesnt work in reverse... because... it's not basing it off of the brush size which it should be
|
||||||
|
var lineSizeChange = Math.round(distanceFromClick/10);
|
||||||
|
var newLineSize = tool.line.previousBrushSize + lineSizeChange;
|
||||||
|
|
||||||
|
//set the brush to the new size as long as its bigger than 1
|
||||||
|
tool.line.brushSize = Math.max(1, newLineSize);
|
||||||
|
|
||||||
|
//fix offset so the cursor stays centered
|
||||||
|
tool.line.moveBrushPreview(lastMouseClickPos);
|
||||||
|
currentTool.updateCursor();
|
||||||
|
}
|
||||||
else if (currentTool.name == 'rectselect') {
|
else if (currentTool.name == 'rectselect') {
|
||||||
if (dragging && !isRectSelecting && mouseEvent.target.className == 'drawingCanvas') {
|
if (dragging && !isRectSelecting && mouseEvent.target.className == 'drawingCanvas') {
|
||||||
isRectSelecting = true;
|
isRectSelecting = true;
|
||||||
|
64
js/tools/_all.js
Normal file
64
js/tools/_all.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
new Tool('eraser', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
brushPreview: true,
|
||||||
|
});
|
||||||
|
new Tool('resizeeraser', {
|
||||||
|
cursor: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('eyedropper', {
|
||||||
|
imageCursor: 'eyedropper',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('fill', {
|
||||||
|
imageCursor: 'fill',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('line', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
brushPreview: true,
|
||||||
|
});
|
||||||
|
new Tool('resizeline', {
|
||||||
|
cursor: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('pan', {
|
||||||
|
cursor: function () {
|
||||||
|
if (dragging) return 'url(\'/pixel-editor/pan-held.png\'), auto';
|
||||||
|
else return 'url(\'/pixel-editor/pan.png\'), auto';
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('pencil', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
brushPreview: true,
|
||||||
|
});
|
||||||
|
new Tool('resizebrush', {
|
||||||
|
cursor: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('rectangle', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
brushPreview: true,
|
||||||
|
});
|
||||||
|
new Tool('resizerectangle', {
|
||||||
|
cursor: 'default',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('rectselect', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
brushPreview: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
new Tool('moveselection', {
|
||||||
|
cursor: 'crosshair',
|
||||||
|
});
|
||||||
|
|
||||||
|
new Tool('zoom', {
|
||||||
|
imageCursor: 'zoom-in',
|
||||||
|
});
|
||||||
|
|
||||||
|
//set a default tool
|
||||||
|
var currentTool = tool.pencil;
|
||||||
|
var currentToolTemp = tool.pencil;
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
new Tool('eraser', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
brushPreview: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
new Tool('resizeeraser', {
|
|
||||||
cursor: 'default',
|
|
||||||
});
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
new Tool('eyedropper', {
|
|
||||||
imageCursor: 'eyedropper',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,7 +0,0 @@
|
|||||||
|
|
||||||
new Tool('fill', {
|
|
||||||
imageCursor: 'fill',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,8 +0,0 @@
|
|||||||
new Tool('line', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
brushPreview: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
new Tool('resizeline', {
|
|
||||||
cursor: 'default',
|
|
||||||
});
|
|
@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
new Tool('pan', {
|
|
||||||
cursor: function () {
|
|
||||||
if (dragging) return 'url(\'/pixel-editor/pan-held.png\'), auto';
|
|
||||||
else return 'url(\'/pixel-editor/pan.png\'), auto';
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
new Tool('pencil', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
brushPreview: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
new Tool('resizebrush', {
|
|
||||||
cursor: 'default',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
//set as default tool
|
|
||||||
var currentTool = tool.pencil;
|
|
||||||
var currentToolTemp = tool.pencil;
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
new Tool('rectangle', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
brushPreview: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
new Tool('resizerectangle', {
|
|
||||||
cursor: 'default',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
new Tool('rectselect', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
brushPreview: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
new Tool('moveselection', {
|
|
||||||
cursor: 'crosshair',
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
new Tool('zoom', {
|
|
||||||
imageCursor: 'zoom-in',
|
|
||||||
});
|
|
||||||
|
|
||||||
/*global Tool, tool*/
|
|
Loading…
x
Reference in New Issue
Block a user