2-column open source credits

This commit is contained in:
2024-11-19 14:13:12 -06:00
parent 17e297ea32
commit bf91f41675
9 changed files with 85 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
Confirmed:
- The Almighty Doer of Stuff
- The Almighty
Doer of Stuff
- Mistb0rn
- Celtic Minstrel
- Kelyar-Ihrno

View File

@@ -1,2 +1,3 @@
Confirmed:
- The Almighty Doer of Stuff
- The Almighty
Doer of Stuff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -19,7 +19,9 @@ def get_confirmed_names(filename):
# After the confirmed names, there may be Not Confirmed: names.
if 'Not Confirmed:' in lines:
lines = lines[0:lines.index('Not Confirmed:')]
return [line.replace('- ', '') for line in lines if len(line) > 0]
# Lines should either start with "- " or " " if continuing the previous name, wrapped and indented:
return [line[2:] for line in lines if len(line) > 0]
def main():
# Generate about-boe.xml from about-boe-template.xml:
@@ -83,19 +85,59 @@ def main():
output_file.write(content)
# Generate startanim.png using ImageMagick
image_lines = ['* OPEN SOURCE CREDITS *', ' ', ' ']
image_lines_col1 = []
image_lines_col2 = []
# Note: blank lines need to have a space in them for some reason
def add_heading(heading):
image_lines.append(f'- {heading.upper()} -')
image_lines.extend(" ")
image_lines.extend(name_dict[heading])
image_lines.extend(" ")
image_lines_col1.append(f'- {heading.upper()} -')
image_lines_col1.append(' ')
image_lines_col2.extend([' ', ' '])
# (Complicated)
# Split the names into two columns, still vertically alphabetized,
# while keeping multi-line names on the same column!
names = name_dict[heading]
left_column = True
idx = 0
while idx < len(names):
current_column = image_lines_col1 if left_column else image_lines_col2
current_column.append(names[idx])
multiline_idx = idx + 1
while multiline_idx < len(names) and names[multiline_idx].startswith(' '):
current_column.append(names[multiline_idx])
multiline_idx += 1
idx += 1
left_column = len(image_lines_col1) <= len(image_lines_col2)
idx += 1
while len(image_lines_col1) != len(image_lines_col2):
current_column = image_lines_col1 if left_column else image_lines_col2
current_column.append(' ')
image_lines_col1.append(' ')
image_lines_col2.append(' ')
add_heading('Programming')
add_heading('Graphics')
add_heading('Testing')
add_heading('Funding')
run(['bash', 'pkg/generate-startanim.sh'], input='\n'.join(image_lines), encoding='ascii')
# when one column starts with blank lines, ImageMagick doesn't offset the top correctly.
# So we pass the number of lines to y-offset the right column image
col2_blank_lines_start = 0
for line in image_lines_col2:
if line == ' ':
col2_blank_lines_start += 1
else:
break
run(['bash', 'pkg/generate-startanim-col.sh', '1', '0'], input='\n'.join(image_lines_col1), encoding='ascii')
# print(col2_blank_lines_start)
run(['bash', 'pkg/generate-startanim-col.sh', '2', str(col2_blank_lines_start)], input='\n'.join(image_lines_col2), encoding='ascii')
run(['bash', 'pkg/generate-startanim.sh'])
if __name__ == "__main__":
main()

16
pkg/generate-startanim-col.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
text="$(cat)"
line_count=$(echo "$text" | wc -l)
font_size=8
spacing=5
actual_line_size=$((font_size + spacing))
top_offset_lines=$2
first_line_offset=$((font_size + 2 + actual_line_size * top_offset_lines))
height=$((actual_line_size * line_count))
magick -size 140x$height xc:transparent \
-stroke black -pointsize $font_size -interline-spacing $spacing \
-font 'pkg/credits/font-8.bdf' -annotate +7+$first_line_offset "$text" \
pkg/credits/startanim-col-$1.png

View File

@@ -1,17 +1,7 @@
#!/bin/bash
text="$(cat)"
line_count=$(echo "$text" | wc -l)
font_size=8
spacing=5
actual_line_size=$((font_size + spacing))
first_line_offset=$((font_size + 2))
height=$((actual_line_size * line_count))
magick -size 280x$height xc:transparent \
-stroke black -pointsize $font_size -interline-spacing $spacing \
-font 'pkg/credits/font-8.bdf' -annotate +7+$first_line_offset "$text" \
pkg/credits/startanim-pt-2.png
magick convert -append pkg/credits/startanim-pt-*.png rsrc/graphics/startanim.png
magick convert +append pkg/credits/startanim-col-*.png pkg/credits/startanim-pt-2.png
magick convert -append pkg/credits/startanim-pt-*.png rsrc/graphics/startanim.png
# Clean up:
rm pkg/credits/startanim-col-*.png
rm pkg/credits/startanim-pt-2.png