diff --git a/canvas.js b/canvas.js index a1e5654..03dfbd3 100644 --- a/canvas.js +++ b/canvas.js @@ -8,6 +8,21 @@ var customColorToolbar=false; document.addEventListener("DOMContentLoaded",()=>{ + + class Coordinate{ + constructor(box) { + var idParse=box.id.split("_"); + this.x = idParse[1]; + this.y = idParse[2]; + } + } + class PixelCoordinate extends Coordinate{ + constructor(x,y) { + this.x = x; + this.y = y; + } + } + function insertAfter(newNode, existingNode) { existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling); } @@ -37,6 +52,7 @@ document.addEventListener("DOMContentLoaded",()=>{ var MouseStateUp = (e)=>{ e.preventDefault(); mouseState = -1; + toolbar.style.visibility = "visible"; } var MouseStateDown = (e)=>{ e.preventDefault(); @@ -48,6 +64,7 @@ document.addEventListener("DOMContentLoaded",()=>{ e.target.style.background="white"; } } + toolbar.style.visibility = "hidden"; } var colorPixelBasedOnID = (x,y,color)=>{ @@ -57,6 +74,7 @@ document.addEventListener("DOMContentLoaded",()=>{ var generateTable = (columns,rows)=>{ var table = document.createElement("table"); + table.style.border="1px gray dashed"; for (var i=0;i{ for (var i=0;i{ var row = table.getElementsByTagName("tr")[i] var col = document.createElement("th"); col.style.background="white"; + col.style.border=document.querySelector("table").style.border; col.id="pos_"+COLS+"_"+i; row.appendChild(col); } @@ -288,6 +308,31 @@ document.addEventListener("DOMContentLoaded",()=>{ saveButton.addEventListener("click",SaveData) toolbar.appendChild(loadButton); toolbar.appendChild(saveButton); + var toggleGridButton = document.createElement("img"); + toggleGridButton.src = "gridtoggle.png"; + toggleGridButton.classList.add("tinybutton"); + toggleGridButton.addEventListener("click",()=>{ + var elements = document.querySelectorAll("table,tr,th") + if (document.querySelector("body > div.container > div > table").style.border.includes("1px")) { + for (var item of elements) { + item.style.border = "0px"; + } + } else { + for (var item of elements) { + item.style.border = "1px gray dashed"; + } + } + }) + toolbar.appendChild(toggleGridButton); + } + + //Returns a coordinate class. + var getCoordinates = (box)=>{ + return new Coordinate(box); + } + + var floodFill = (startx,starty)=>{ + } generateTable(ROWS,COLS); diff --git a/filltool.png b/filltool.png new file mode 100644 index 0000000..e4b2293 Binary files /dev/null and b/filltool.png differ diff --git a/gridtoggle.png b/gridtoggle.png new file mode 100644 index 0000000..6c05900 Binary files /dev/null and b/gridtoggle.png differ diff --git a/style.css b/style.css index c4cac48..03776f9 100644 --- a/style.css +++ b/style.css @@ -1,4 +1,4 @@ -table,td,th{ +table,tr,th{ border:1px gray dashed; border-spacing:0px; gap:0px; @@ -12,6 +12,9 @@ th{ .container{ text-align: center; } +.toolbar{ + width: 100%; +} .canvas{ display:inline-block; background-color: #EEEEFF; @@ -52,4 +55,16 @@ th{ display: inline-block; border:2px black solid; margin-left:1px; +} +.tinybutton{ + margin-top:-24px; + position:relative; + top: 6px; + height: 24px; + width: 24px; + background-color: #bbb; + border-radius: 50%; + display: inline-block; + border:2px black solid; + margin-left:1px; } \ No newline at end of file