pointvec/sources/scripts/guide.js

33 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-11-09 14:47:06 -05:00
function Guide()
{
this.el = document.createElement("div");
// Guide
this.el.id = "guide";
2017-11-12 15:14:00 -05:00
this.markers;
2017-11-09 14:47:06 -05:00
this.start = function()
{
// Markers
2017-11-12 15:14:00 -05:00
this.markers = JSON.parse("["+"[],".repeat(dotgrid.grid_x)+"[]"+"]")
2017-11-09 14:47:06 -05:00
for (var x = dotgrid.grid_x; x >= 0; x--) {
for (var y = dotgrid.grid_y; y >= 0; y--) {
2017-11-12 15:14:00 -05:00
let marker = document.createElement("div");
2017-11-09 14:47:06 -05:00
marker.setAttribute("class",(x % dotgrid.block_x == 0 && y % dotgrid.block_y == 0 ? "marker bm" : "marker bl"));
2017-11-12 15:14:00 -05:00
marker.style.left = parseInt(x * dotgrid.grid_width + (dotgrid.grid_width/2)) ;
marker.style.top = parseInt(y * dotgrid.grid_height + (dotgrid.grid_height/2)) ;
2017-11-09 14:47:06 -05:00
this.el.appendChild(marker);
2017-11-12 15:14:00 -05:00
this.markers[x][y] = marker
}
}
}
this.update = function() // it's less than ideal to reuse this much code, but I couldn't find a way to reuse the function that wouldn't mess with the architecture
{
for (var x = dotgrid.grid_x; x >= 0; x--) {
for (var y = dotgrid.grid_y; y >= 0; y--) {
let marker = this.markers[x][y]
marker.style.left = parseInt(x * dotgrid.grid_width + (dotgrid.grid_width/2) +(5*dotgrid.scale));
marker.style.top = parseInt(y * dotgrid.grid_height + (dotgrid.grid_height/2) +(5*dotgrid.scale));
2017-11-09 14:47:06 -05:00
}
}
}
}