(
group_iter,
num_cells,
start_col,
start_row,
x_direction,
y_direction
)
| 932 | } |
| 933 | |
| 934 | get_end_points( |
| 935 | group_iter, |
| 936 | num_cells, |
| 937 | start_col, |
| 938 | start_row, |
| 939 | x_direction, |
| 940 | y_direction |
| 941 | ) { |
| 942 | //start_row is the 0-based index and not a 1-based index, i.e., it |
| 943 | //is not the column number in the truest sense |
| 944 | // Function to get the end points of the rectangle representing the |
| 945 | // groups. |
| 946 | // Requires the direction variables to be updated before this |
| 947 | // function is called |
| 948 | let top_row = this.row_limits[group_iter - 1]; |
| 949 | let bottom_row = this.row_limits[group_iter]; |
| 950 | let across = false; |
| 951 | |
| 952 | let init_x = x_direction; |
| 953 | let init_y = y_direction; |
| 954 | const end_points = []; |
| 955 | let current_row; |
| 956 | |
| 957 | const rows_remaining = |
| 958 | init_y == 1 ? bottom_row - start_row : start_row - top_row + 1; |
| 959 | let cols_remaining = |
| 960 | init_x == 1 ? this.num_cols - 1 - start_col : start_col; // this is the num of columns remaining |
| 961 | //after the cuirrent column has been filled |
| 962 | let elem_remaining = num_cells; |
| 963 | //this holds the number of continuous cols that will be filled |
| 964 | //between the current top and bottom rows |
| 965 | let num_rows = bottom_row - top_row; |
| 966 | |
| 967 | if (elem_remaining !== 0) { |
| 968 | // starting corner of the path |
| 969 | this.calc_end_point_source(start_col, start_row, init_x, init_y).forEach( |
| 970 | (d) => { |
| 971 | end_points.push(d); |
| 972 | } |
| 973 | ); |
| 974 | const elem_filled = Math.min(rows_remaining, elem_remaining); |
| 975 | |
| 976 | if (elem_filled === elem_remaining) { |
| 977 | // There are enough elements only to fill one column |
| 978 | // partially. We add the three end points and exit |
| 979 | // The adjacent corner from the starting corner. This is |
| 980 | // required because the elements are filled in the first |
| 981 | // row itself. |
| 982 | this.calc_end_point_source( |
| 983 | start_col, |
| 984 | start_row, |
| 985 | -1 * init_x, |
| 986 | init_y |
| 987 | ).forEach((d) => { |
| 988 | end_points.push(d); |
| 989 | }); |
| 990 | |
| 991 | current_row = start_row + (elem_remaining - 1) * init_y; |
no test coverage detected