Skip to content

Commit 324c3aa

Browse files
committed
increased size of publicity grid
1 parent 415b0d3 commit 324c3aa

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

exec/publicity.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
# max grid size for single week
3636
MAX_GRID_COLS = 4
37-
MAX_GRID_ROWS = 2
37+
MAX_GRID_ROWS = 3
3838

3939
# 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)]
4141

4242
# spacing of days in single week
4343
DAY_TEXT_HEIGHT = 125
@@ -312,10 +312,10 @@ def get_event_groups(
312312
combinations = {
313313
1: [[1, 1]],
314314
2: [[2, 1], [1, 2]],
315-
3: [[3, 1], [2, 2]],
315+
3: [[3, 1], [2, 2], [1, 3]],
316316
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]],
319319
}
320320

321321
# get possible sizes of grids
@@ -548,7 +548,9 @@ def create_single_week( # noqa: PLR0912, PLR0915
548548
num_rows, num_cols = len(grid), len(grid[0])
549549

550550
# 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+
)
552554
grid_width = POST_WIDTH
553555
grid_top = POST_HEIGHT / 4 + (POST_HEIGHT - POST_HEIGHT / 4 - grid_height) / 2
554556

@@ -595,7 +597,6 @@ def create_single_week( # noqa: PLR0912, PLR0915
595597
base_x = grid_left + base_col * cell_width
596598
base_y = grid_top + base_row * cell_height
597599
centre_y = base_y + col_width * cell_height / 2 + DAY_TEXT_HEIGHT / 2
598-
centre_x = base_x + row_width * cell_width / 2
599600

600601
if day == "Socials":
601602
# apply socials box if necessary
@@ -630,28 +631,30 @@ def create_single_week( # noqa: PLR0912, PLR0915
630631
]
631632
)
632633

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+
635638
# 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
637640
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
639642
)
640643

641644
# 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
650650

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
653653
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+
]
655658
elements.append(event_circle)
656659

657660
return elements

0 commit comments

Comments
 (0)