dl = document.getElementById("dload");
dl.onclick = demoHandler;
demoHandler(null);
+
+}
+
+radius_hover = function(e) {
+ let rad = parseInt(document.getElementById('rad').value);
+ let gcoord = getClickCoords(c,scale,xcenter,ycenter,e);
+ let cell = g.cellAt(gcoord.q, gcoord.r);
+ // does this belong here? maybe it's okay...
+ let ccoords = cell.getCanvasCoords(xcenter, ycenter, scale);
+ drawGrid(g, ctx, xcenter,ycenter,scale);
+ ctx.save();
+ ctx.fillStyle = "rgba(0.3,0.3,0.3,0.1)";
+ ctx.strokeStyle = "rgba(0.3,0.3,0.3,0.1)";
+ let r = (rad-.5) * scale * Math.sqrt(3);
+ let x = ccoords.x;
+ let y = ccoords.y;
+ ctx.beginPath();
+ ctx.moveTo(x+r,y);
+ for(let i=1; i<7; i++) {
+ ctx.lineTo(x+ r*Math.cos(Math.PI*i/3), y+r*Math.sin(Math.PI*i/3));
+ }
+ ctx.fill();
+ ctx.stroke();
+ ctx.restore();
}
rangeManage = function(e) {
rotateButtonHandler = function(e) {
c.onclick = e=>rotateThingy(e);
+ c.addEventListener('mousemove', radius_hover);
+
// tf are those arguments globals are there for a reason
ctx.save();
ctx.fillStyle="rgba(0.4,0.4,0.4,0.1)"
ctx.restore();
}
rotateThingy = function(evt) {
+ c.removeEventListener('mousemove', radius_hover);
let coords = getClickCoords(c,scale,xcenter,ycenter,evt);
let rad = parseInt(document.getElementById('rad').value);
g.rotateHex(coords.q,coords.r,rad);
copyHandler = function(e) {
c.onclick = e=>copyhex(e);
+ c.addEventListener('mousemove', radius_hover);
ctx.save();
ctx.fillStyle="rgba(0.4,0.4,0.4,0.1)"
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height);
}
copyhex = function(evt) {
+ c.removeEventListener('mousemove', radius_hover);
let coords = getClickCoords(c,scale,xcenter,ycenter,evt);
let rad = parseInt(document.getElementById('rad').value);
copybuf = g.copyHex(coords.q, coords.r, rad)
}
pasteHandler = function(e) {
c.onclick = e=>pastehex(e);
+ c.addEventListener('mousemove', radius_hover);
ctx.save();
ctx.fillStyle="rgba(0.4,0.4,0.4,0.1)"
ctx.fillRect(0,0,ctx.canvas.width,ctx.canvas.height);
ctx.restore();
}
pastehex = function(evt) {
+ c.removeEventListener('mousemove', radius_hover);
let coords = getClickCoords(c,scale,xcenter,ycenter,evt);
let rad = parseInt(document.getElementById('rad').value);
g.pasteHex(coords.q,coords.r,copybuf);