@@ -33,6 +33,7 @@ static void run_these_tests(
3333static void test_rects (struct canvas * c );
3434static void test_circles (struct canvas * c );
3535static void test_lines_burst (struct canvas * c );
36+ static void test_lines_array (struct canvas * c );
3637static void test_copy_rect (struct canvas * c );
3738static void test_bezier2 (struct canvas * c );
3839
@@ -60,6 +61,13 @@ void run_tests(const char *dump_dir)
6061 .width = 32 ,
6162 .height = 32 ,
6263 },
64+ {
65+ .fill_color = BG ,
66+ .draw_fn = test_lines_array ,
67+ .output_path = "lines-array.data" ,
68+ .width = 128 ,
69+ .height = 128 ,
70+ },
6371 {
6472 .fill_color = BG ,
6573 .draw_fn = test_copy_rect ,
@@ -229,6 +237,45 @@ static void test_lines_burst(struct canvas *c)
229237 }
230238}
231239
240+ static void test_lines_array (struct canvas * c )
241+ {
242+ const int32_t cols = 7 ;
243+ const int32_t rows = 13 ;
244+ const int32_t gap = 1 ;
245+
246+ const int32_t col_len = c -> width / cols ;
247+ const int32_t row_len = c -> height / rows ;
248+
249+ for (int32_t col = 0 ; col < cols ; col ++ ) {
250+ for (int32_t row = 0 ; row < rows ; row ++ ) {
251+ int32_t col_start = col * c -> width / cols ;
252+ int32_t row_start = row * c -> height / rows ;
253+ int32_t cx = col_start + col_len / 2 ;
254+ int32_t cy = row_start + row_len / 2 ;
255+
256+ float p = (float )(cols * row + col ) /
257+ ((float )cols * (float )rows );
258+
259+ rendering_draw_line (c ,
260+ & (struct line ) {
261+ .x0 = cx +
262+ roundf (cosf (p * TAU ) *
263+ ((float )col_len / 2 - gap )),
264+ .y0 = cy +
265+ roundf (sinf (p * TAU ) *
266+ ((float )row_len / 2 - gap )),
267+ .x1 = cx +
268+ roundf (cosf (p * TAU + PI ) *
269+ ((float )col_len / 2 - gap )),
270+ .y1 = cy +
271+ roundf (sinf (p * TAU + PI ) *
272+ ((float )row_len / 2 - gap )),
273+ .c = FG ,
274+ });
275+ }
276+ }
277+ }
278+
232279static void test_copy_rect (struct canvas * c )
233280{
234281 // Fill the screen with something.
@@ -308,8 +355,8 @@ static void test_bezier2(struct canvas *c)
308355
309356 for (int32_t col = 0 ; col < cols ; col ++ ) {
310357 for (int32_t row = 0 ; row < rows ; row ++ ) {
311- int32_t col_start = col * col_len ;
312- int32_t row_start = row * row_len ;
358+ int32_t col_start = col * c -> width / cols ;
359+ int32_t row_start = row * c -> height / rows ;
313360 int32_t dx = col * col_len / cols ;
314361 int32_t dy = row * row_len / rows ;
315362
0 commit comments