mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Connected events to rect selection
_rectSelect.js now knows when the user started and finished drawing a rect and is able to edit a preview.
This commit is contained in:
parent
cba4e5c87e
commit
efaa8e3c34
@ -63,6 +63,11 @@ svg {
|
|||||||
background:transparent;
|
background:transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pixel-canvas {
|
||||||
|
z-index:1000;
|
||||||
|
background:transparent;
|
||||||
|
}
|
||||||
|
|
||||||
#eyedropper-preview {
|
#eyedropper-preview {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 45px;
|
width: 45px;
|
||||||
|
@ -78,8 +78,6 @@ window.addEventListener("mouseup", function (mouseEvent) {
|
|||||||
eyedropperPreview.style.display = 'none';
|
eyedropperPreview.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (currentTool == 'fill' && mouseEvent.target == currentLayer.canvas) {
|
else if (currentTool == 'fill' && mouseEvent.target == currentLayer.canvas) {
|
||||||
console.log('filling')
|
console.log('filling')
|
||||||
@ -111,6 +109,9 @@ window.addEventListener("mouseup", function (mouseEvent) {
|
|||||||
layers[i].copyData(layers[0]);
|
layers[i].copyData(layers[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (currentTool == 'rectselect') {
|
||||||
|
endRectSelection();
|
||||||
|
}
|
||||||
|
|
||||||
dragging = false;
|
dragging = false;
|
||||||
currentTool = currentToolTemp;
|
currentTool = currentToolTemp;
|
||||||
@ -237,6 +238,15 @@ function draw (mouseEvent) {
|
|||||||
|
|
||||||
updateCursor();
|
updateCursor();
|
||||||
}
|
}
|
||||||
|
else if (currentTool == 'rectselect') {
|
||||||
|
if (dragging && !isRectSelecting) {
|
||||||
|
isRectSelecting = true;
|
||||||
|
startRectSelection();
|
||||||
|
}
|
||||||
|
else if (dragging && isRectSelecting) {
|
||||||
|
updateRectSelection();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//mousewheel scrroll
|
//mousewheel scrroll
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
|
|
||||||
function newPixel (width, height, palette) {
|
function newPixel (width, height, palette) {
|
||||||
|
// Setting the current layer
|
||||||
currentLayer = new Canvas(width, height, canvas);
|
currentLayer = new Canvas(width, height, canvas);
|
||||||
currentLayer.initialize();
|
currentLayer.initialize();
|
||||||
|
|
||||||
|
// Adding the checkerboard behind it
|
||||||
checkerBoard = new Canvas(width, height, checkerBoardCanvas);
|
checkerBoard = new Canvas(width, height, checkerBoardCanvas);
|
||||||
checkerBoard.initialize();
|
checkerBoard.initialize();
|
||||||
|
|
||||||
|
// Creating the vfx layer on top of everything
|
||||||
|
VFXLayer = new Canvas(width, height, VFXCanvas);
|
||||||
|
VFXLayer.initialize();
|
||||||
|
|
||||||
canvasSize = currentLayer.canvasSize;
|
canvasSize = currentLayer.canvasSize;
|
||||||
|
|
||||||
|
// Adding the first layer and the checkerboard to the list of layers
|
||||||
|
layers.push(VFXLayer);
|
||||||
layers.push(currentLayer);
|
layers.push(currentLayer);
|
||||||
layers.push(checkerBoard);
|
layers.push(checkerBoard);
|
||||||
|
|
||||||
|
13
js/_rectSelect.js
Normal file
13
js/_rectSelect.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
var isRectSelecting = false;
|
||||||
|
|
||||||
|
function startRectSelection() {
|
||||||
|
console.log("Started selecting");
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateRectSelection() {
|
||||||
|
console.log("Editing selecting");
|
||||||
|
}
|
||||||
|
|
||||||
|
function endRectSelection() {
|
||||||
|
console.log("Finished selecting");
|
||||||
|
}
|
@ -38,3 +38,8 @@ var layers = [];
|
|||||||
// Currently selected layer
|
// Currently selected layer
|
||||||
var currentLayer;
|
var currentLayer;
|
||||||
|
|
||||||
|
// VFX layer used to draw previews of the selection and things like that
|
||||||
|
var VFXLayer;
|
||||||
|
// VFX canvas
|
||||||
|
var VFXCanvas = document.getElementById("vfx-canvas");
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
//=include _clickedColor.js
|
//=include _clickedColor.js
|
||||||
//=include _fileMenu.js
|
//=include _fileMenu.js
|
||||||
//=include _createButton.js
|
//=include _createButton.js
|
||||||
|
//=include _rectSelect.js
|
||||||
|
|
||||||
|
|
||||||
/**onload**/
|
/**onload**/
|
||||||
|
@ -103,6 +103,7 @@
|
|||||||
<div id="brush-preview"></div>
|
<div id="brush-preview"></div>
|
||||||
|
|
||||||
<div id="canvas-view">
|
<div id="canvas-view">
|
||||||
|
<canvas id="vfx-canvas" class = "drawingCanvas"></canvas>
|
||||||
<canvas id="pixel-canvas" class = "drawingCanvas"></canvas>
|
<canvas id="pixel-canvas" class = "drawingCanvas"></canvas>
|
||||||
<canvas id="checkerboard" class = "drawingCanvas"></canvas>
|
<canvas id="checkerboard" class = "drawingCanvas"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user