|
34 | 34 |
|
35 | 35 | # max grid size for single week |
36 | 36 | MAX_GRID_COLS = 4 |
37 | | -MAX_GRID_ROWS = 2 |
| 37 | +MAX_GRID_ROWS = 3 |
38 | 38 |
|
39 | 39 | # the options for sizes of a grid |
40 | | -GRID_SIZES = [(2, 1), (2, 2), (3, 2), (4, 2)] |
| 40 | +GRID_SIZES = [(2, 1), (2, 2), (3, 2), (4, 2), (4, 3), (4, 3)] |
41 | 41 |
|
42 | 42 | # spacing of days in single week |
43 | 43 | DAY_TEXT_HEIGHT = 125 |
@@ -312,10 +312,10 @@ def get_event_groups( |
312 | 312 | combinations = { |
313 | 313 | 1: [[1, 1]], |
314 | 314 | 2: [[2, 1], [1, 2]], |
315 | | - 3: [[3, 1], [2, 2]], |
| 315 | + 3: [[3, 1], [2, 2], [1, 3]], |
316 | 316 | 4: [[2, 2], [4, 1]], |
317 | | - 5: [[3, 2], [4, 2]], |
318 | | - 6: [[3, 2], [4, 2]], |
| 317 | + 5: [[3, 2], [2, 3], [4, 2]], |
| 318 | + 6: [[3, 2], [2, 3], [4, 2]], |
319 | 319 | } |
320 | 320 |
|
321 | 321 | # get possible sizes of grids |
@@ -548,7 +548,9 @@ def create_single_week( # noqa: PLR0912, PLR0915 |
548 | 548 | num_rows, num_cols = len(grid), len(grid[0]) |
549 | 549 |
|
550 | 550 | # find position and sizing of grid |
551 | | - grid_height = POST_HEIGHT / 1.5 |
| 551 | + grid_height = ( |
| 552 | + (POST_HEIGHT / 1.5) if num_rows < 3 else (POST_HEIGHT / 1.35) # noqa: PLR2004 |
| 553 | + ) |
552 | 554 | grid_width = POST_WIDTH |
553 | 555 | grid_top = POST_HEIGHT / 4 + (POST_HEIGHT - POST_HEIGHT / 4 - grid_height) / 2 |
554 | 556 |
|
@@ -595,7 +597,6 @@ def create_single_week( # noqa: PLR0912, PLR0915 |
595 | 597 | base_x = grid_left + base_col * cell_width |
596 | 598 | base_y = grid_top + base_row * cell_height |
597 | 599 | centre_y = base_y + col_width * cell_height / 2 + DAY_TEXT_HEIGHT / 2 |
598 | | - centre_x = base_x + row_width * cell_width / 2 |
599 | 600 |
|
600 | 601 | if day == "Socials": |
601 | 602 | # apply socials box if necessary |
@@ -630,28 +631,30 @@ def create_single_week( # noqa: PLR0912, PLR0915 |
630 | 631 | ] |
631 | 632 | ) |
632 | 633 |
|
633 | | - for row in range(col_width): |
634 | | - for col in range(row_width): |
| 634 | + for col in range(col_width): |
| 635 | + for row in range(row_width): |
| 636 | + event_scale = 0.7 if num_rows == 3 else 1.0 # noqa: PLR2004 |
| 637 | + |
635 | 638 | # work out extra translation required |
636 | | - translate_x = base_x + col * cell_width + cell_width / 2 |
| 639 | + translate_x = base_x + row * cell_width + cell_width / 2 |
637 | 640 | translate_y = ( |
638 | | - base_y + row * cell_height + cell_height / 2 + DAY_TEXT_HEIGHT / 2 |
| 641 | + base_y + col * cell_height + cell_height / 2 + DAY_TEXT_HEIGHT / 2 |
639 | 642 | ) |
640 | 643 |
|
641 | 644 | # if spanning multiple columns, pull towards centre |
642 | | - pull = 0 if col_width == 1 else pull_factor |
643 | | - translate_y = (1 - pull) * translate_y + pull * centre_y |
644 | | - pull = ( |
645 | | - 0 |
646 | | - if row_width == 1 or num_cols != 3 # noqa: PLR2004 |
647 | | - else pull_factor |
648 | | - ) |
649 | | - translate_x = (1 - pull) * translate_x + pull * centre_x |
| 645 | + pull_y = 0 if col_width == 1 else pull_factor |
| 646 | + translate_y = (1 - pull_y) * translate_y + pull_y * centre_y |
| 647 | + |
| 648 | + translate_x /= event_scale |
| 649 | + translate_y /= event_scale |
650 | 650 |
|
651 | | - # create event circle and apply offset |
652 | | - event_idx = row * row_width + col |
| 651 | + # create event circle and apply offset + scaling around its center |
| 652 | + event_idx = col * row_width + row |
653 | 653 | event_circle = get_event_circle(day_event_list[event_idx]) |
654 | | - event_circle.transform = [svg.Translate(translate_x, translate_y)] |
| 654 | + event_circle.transform = [ |
| 655 | + svg.Scale(event_scale), |
| 656 | + svg.Translate(translate_x, translate_y), |
| 657 | + ] |
655 | 658 | elements.append(event_circle) |
656 | 659 |
|
657 | 660 | return elements |
|
0 commit comments