mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added eraser icon, added management of eraser size, added event listener for R key (connected to the eraser tool). Started eraser cursor management in _updateCursors.js
Signed-off-by: npalomba <nicola.palomba@studenti.galileilivorno.gov.it>
This commit is contained in:
parent
ed34980a0e
commit
5bbfff5fae
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ _ext
|
|||||||
routes
|
routes
|
||||||
build
|
build
|
||||||
node_modules
|
node_modules
|
||||||
|
.idea
|
@ -414,19 +414,23 @@ svg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#tools-menu li button#pencil-bigger-button,
|
#tools-menu li button#pencil-bigger-button,
|
||||||
#tools-menu li button#zoom-in-button {
|
#tools-menu li button#zoom-in-button,
|
||||||
|
#tools-menu li button#eraser-bigger-button{
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tools-menu li button#pencil-smaller-button,
|
#tools-menu li button#pencil-smaller-button,
|
||||||
#tools-menu li button#zoom-out-button {
|
#tools-menu li button#zoom-out-button,
|
||||||
|
#tools-menu li button#eraser-smaller-button{
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#tools-menu li.selected button#pencil-bigger-button,
|
#tools-menu li.selected button#pencil-bigger-button,
|
||||||
#tools-menu li.selected button#pencil-smaller-button,
|
#tools-menu li.selected button#pencil-smaller-button,
|
||||||
#tools-menu li.selected button#zoom-in-button,
|
#tools-menu li.selected button#zoom-in-button,
|
||||||
#tools-menu li.selected button#zoom-out-button {
|
#tools-menu li.selected button#zoom-out-button,
|
||||||
|
#tools-menu li.selected button#eraser-bigger-button,
|
||||||
|
#tools-menu li.selected button#eraser-smaller-button{
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
images/eraser.png
Normal file
BIN
images/eraser.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
@ -33,6 +33,10 @@ function KeyPress(e) {
|
|||||||
case 53:
|
case 53:
|
||||||
changeTool('zoom');
|
changeTool('zoom');
|
||||||
break;
|
break;
|
||||||
|
// eraser -6, r
|
||||||
|
case 54: case 72:
|
||||||
|
changeTool('eraser');
|
||||||
|
break;
|
||||||
//Z
|
//Z
|
||||||
case 90:
|
case 90:
|
||||||
console.log('PRESSED Z ', keyboardEvent.ctrlKey)
|
console.log('PRESSED Z ', keyboardEvent.ctrlKey)
|
||||||
|
@ -1,18 +1,35 @@
|
|||||||
//pencil
|
//pencil
|
||||||
on('click',"pencil-button", function(){
|
on('click',"pencil-button", function(){
|
||||||
changeTool('pencil');
|
changeTool('pencil');
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
//pencil bigger
|
//pencil bigger
|
||||||
on('click',"pencil-bigger-button", function(){
|
on('click',"pencil-bigger-button", function(){
|
||||||
brushSize++;
|
brushSize++;
|
||||||
updateCursor();
|
updateCursor();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
//pencil smaller
|
//pencil smaller
|
||||||
on('click',"pencil-smaller-button", function(e){
|
on('click',"pencil-smaller-button", function(){
|
||||||
if(brushSize > 1) brushSize--;
|
if(brushSize > 1) brushSize--;
|
||||||
updateCursor();
|
updateCursor();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
//eraser
|
||||||
|
on('click',"eraser-button", function(){
|
||||||
|
changeTool('eraser');
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
//eraser bigger
|
||||||
|
on('click',"eraser-bigger-button", function(){
|
||||||
|
eraserSize++;
|
||||||
|
updateCursor();
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
//eraser smaller
|
||||||
|
on('click',"eraser-smaller-button", function(e){
|
||||||
|
if(eraserSize > 1) eraserSize--;
|
||||||
|
updateCursor();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
//fill
|
//fill
|
||||||
|
@ -6,6 +6,12 @@ function updateCursor () {
|
|||||||
brushPreview.style.display = 'block';
|
brushPreview.style.display = 'block';
|
||||||
brushPreview.style.width = brushSize * zoom + 'px';
|
brushPreview.style.width = brushSize * zoom + 'px';
|
||||||
brushPreview.style.height = brushSize * zoom + 'px';
|
brushPreview.style.height = brushSize * zoom + 'px';
|
||||||
|
} else if (currentTool == 'eraser') {
|
||||||
|
console.log("Eraser size: " + eraserSize);
|
||||||
|
canvasView.style.cursor = 'crosshair';
|
||||||
|
brushPreview.style.display = 'block';
|
||||||
|
brushPreview.style.width = eraserSize * zoom + 'px';
|
||||||
|
brushPreview.style.height = eraserSize * zoom + 'px';
|
||||||
} else
|
} else
|
||||||
brushPreview.style.display = 'none';
|
brushPreview.style.display = 'none';
|
||||||
|
|
||||||
@ -28,5 +34,4 @@ function updateCursor () {
|
|||||||
|
|
||||||
if (currentTool == 'resize-brush')
|
if (currentTool == 'resize-brush')
|
||||||
canvasView.style.cursor = 'default';
|
canvasView.style.cursor = 'default';
|
||||||
|
|
||||||
}
|
}
|
@ -6,7 +6,9 @@ var canvasPosition;
|
|||||||
var currentTool = 'pencil';
|
var currentTool = 'pencil';
|
||||||
var currentToolTemp = 'pencil';
|
var currentToolTemp = 'pencil';
|
||||||
var brushSize = 1;
|
var brushSize = 1;
|
||||||
|
var eraserSize = 1;
|
||||||
var prevBrushSize = 1;
|
var prevBrushSize = 1;
|
||||||
|
var prevEraserSize = 1;
|
||||||
var menuOpen = false;
|
var menuOpen = false;
|
||||||
var dialogueOpen = false;
|
var dialogueOpen = false;
|
||||||
var documentCreated = false;
|
var documentCreated = false;
|
||||||
|
1543
package-lock.json
generated
1543
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -16,9 +16,9 @@
|
|||||||
"gulp-include": "^2.3.1",
|
"gulp-include": "^2.3.1",
|
||||||
"handlebars-helper-svg": "git+https://bitbucket.org/skeddles/npm-handlebars-helper-svg-lospec-open-source.git",
|
"handlebars-helper-svg": "git+https://bitbucket.org/skeddles/npm-handlebars-helper-svg-lospec-open-source.git",
|
||||||
"hbs": "^4.0.3",
|
"hbs": "^4.0.3",
|
||||||
"opn": "^6.0.0",
|
|
||||||
"sass": "^1.17.3",
|
|
||||||
"hbs-register-helpers": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-helpers.git",
|
"hbs-register-helpers": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-helpers.git",
|
||||||
"hbs-register-partials": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-partials.git"
|
"hbs-register-partials": "git+https://skeddles@bitbucket.org/skeddles/hbs-register-partials.git",
|
||||||
|
"opn": "^6.0.0",
|
||||||
|
"sass": "^1.17.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<img src="/pixel-editor/pan-held.png" />
|
<img src="/pixel-editor/pan-held.png" />
|
||||||
<img src="/pixel-editor/pencil.png" />
|
<img src="/pixel-editor/pencil.png" />
|
||||||
<img src="/pixel-editor/zoom-in.png" />
|
<img src="/pixel-editor/zoom-in.png" />
|
||||||
|
<img src = "/pixel-editor/eraser.png"/>
|
||||||
</div>
|
</div>
|
||||||
<ul id="main-menu">
|
<ul id="main-menu">
|
||||||
<li class="logo">Lospec Pixel Editor</li>
|
<li class="logo">Lospec Pixel Editor</li>
|
||||||
@ -77,6 +78,11 @@
|
|||||||
<button title="Zoom In" id="zoom-in-button" class="tools-menu-sub-button">{{svg "plus.svg" width="12" height="12"}}</button>
|
<button title="Zoom In" id="zoom-in-button" class="tools-menu-sub-button">{{svg "plus.svg" width="12" height="12"}}</button>
|
||||||
<button title="Zoom Out" id="zoom-out-button" class="tools-menu-sub-button">{{svg "minus.svg" width="12" height="12"}}</button>
|
<button title="Zoom Out" id="zoom-out-button" class="tools-menu-sub-button">{{svg "minus.svg" width="12" height="12"}}</button>
|
||||||
</li>
|
</li>
|
||||||
|
<li class = "expanded">
|
||||||
|
<button title="Eraser tool (R)" id="eraser-button">{{svg "eraser.svg" width="32" height="32"}}</button>
|
||||||
|
<button title="Increase Eraser Size" id="eraser-bigger-button" class="tools-menu-sub-button">{{svg "plus.svg" width="12" height="12"}}</button>
|
||||||
|
<button title="Decrease Eraser Size" id="eraser-smaller-button" class="tools-menu-sub-button">{{svg "minus.svg" width="12" height="12"}}</button>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul id="colors-menu">
|
<ul id="colors-menu">
|
||||||
|
Loading…
Reference in New Issue
Block a user