mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
@ -50,6 +50,7 @@ class Layer {
|
||||
if (this.menuEntry !== undefined) {
|
||||
this.name = this.menuEntry.getElementsByTagName("p")[0].innerHTML;
|
||||
this.menuEntry.id = "layer" + id;
|
||||
|
||||
this.menuEntry.onmouseover = () => this.hover();
|
||||
this.menuEntry.onmouseout = () => this.unhover();
|
||||
this.menuEntry.onclick = () => this.selectLayer();
|
||||
@ -63,6 +64,8 @@ class Layer {
|
||||
this.menuEntry.addEventListener("dragleave", this.layerDragLeave, false);
|
||||
this.menuEntry.addEventListener("dragend", this.layerDragEnd, false);
|
||||
|
||||
Events.onCustom("del", this.tryDelete.bind(this));
|
||||
|
||||
this.menuEntry.getElementsByTagName("canvas")[0].getContext('2d').imageSmoothingEnabled = false;
|
||||
}
|
||||
|
||||
@ -73,6 +76,12 @@ class Layer {
|
||||
return this.menuEntry != null;
|
||||
}
|
||||
|
||||
tryDelete() {
|
||||
if (Input.getLastTarget() != this.menuEntry && Input.getLastTarget().parentElement != this.menuEntry)
|
||||
return;
|
||||
LayerList.deleteLayer();
|
||||
}
|
||||
|
||||
// Initializes the canvas
|
||||
initialize() {
|
||||
//resize canvas
|
||||
|
@ -3,7 +3,7 @@ class PixelGrid extends Layer {
|
||||
// Start colour of the pixel grid (can be changed in the preferences)
|
||||
pixelGridColor = "#000000";
|
||||
// Distance between one line and another in HTML pixels
|
||||
lineDistance = 11;
|
||||
lineDistance = 10;
|
||||
// The grid is not visible by default
|
||||
pixelGridVisible = false;
|
||||
// The grid is enabled, but is disabled in order to save performance with big sprites
|
||||
@ -82,6 +82,8 @@ class PixelGrid extends Layer {
|
||||
|
||||
this.context.strokeStyle = Settings.getCurrSettings().pixelGridColour;
|
||||
|
||||
console.log("Line ditance: " + this.lineDistance)
|
||||
|
||||
// OPTIMIZABLE, could probably be a bit more elegant
|
||||
// Draw horizontal lines
|
||||
for (let i=0; i<this.canvas.width / Math.round(this.lineDistance); i++) {
|
||||
|
Reference in New Issue
Block a user