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
}
}
}
}