var grid = 50; var grid_w = to_x + ( m_type == 'rb' ? 20:10 ) ; grid_w = grid_w-grid_w%grid; var grid_h = to_y + ( m_type == 'rb' ? 20:10 ) ; grid_h = grid_h-grid_h%grid;