mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Finished implementing pixel grid
Added possibility to hide / show the grid.
This commit is contained in:
@ -1,7 +1,22 @@
|
|||||||
let pixelGridColor = "#0000FF";
|
let pixelGridColor = "#0000FF";
|
||||||
let lineDistance = 12;
|
let lineDistance = 12;
|
||||||
|
let pixelGridVisible = false;
|
||||||
pixelGridCanvas = document.getElementById("pixel-grid");
|
pixelGridCanvas = document.getElementById("pixel-grid");
|
||||||
|
|
||||||
|
function togglePixelGrid(event) {
|
||||||
|
let button = document.getElementById("toggle-pixelgrid-button");
|
||||||
|
|
||||||
|
pixelGridVisible = !pixelGridVisible;
|
||||||
|
|
||||||
|
if (pixelGridVisible) {
|
||||||
|
button.innerHTML = "Hide pixel grid";
|
||||||
|
pixelGridCanvas.style.display = "inline-block";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
button.innerHTML = "Show pixel grid";
|
||||||
|
pixelGridCanvas.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function fillPixelGrid() {
|
function fillPixelGrid() {
|
||||||
let context = pixelGridCanvas.getContext("2d");
|
let context = pixelGridCanvas.getContext("2d");
|
||||||
@ -30,4 +45,8 @@ function fillPixelGrid() {
|
|||||||
context.stroke();
|
context.stroke();
|
||||||
context.closePath();
|
context.closePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pixelGridVisible) {
|
||||||
|
pixelGridCanvas.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
@ -58,6 +58,12 @@
|
|||||||
<li><button id="redo-button" class="disabled">Redo</button></li>
|
<li><button id="redo-button" class="disabled">Redo</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<button>View</button>
|
||||||
|
<ul>
|
||||||
|
<li><button id="toggle-pixelgrid-button" onclick="togglePixelGrid()">Show pixel grid</button></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button id = "layer-button">Layer</button>
|
<button id = "layer-button">Layer</button>
|
||||||
<ul>
|
<ul>
|
||||||
|
Reference in New Issue
Block a user