Skip to content

Commit

Permalink
Added credits
Browse files Browse the repository at this point in the history
  • Loading branch information
annieqqa committed Mar 1, 2024
1 parent fdfa10d commit 6031c3e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
Binary file modified code/__pycache__/process_img.cpython-310.pyc
Binary file not shown.
28 changes: 15 additions & 13 deletions code/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from docx.shared import Pt

if __name__ == '__main__':
mp.dps=14417 #m* n -1
dps = 14417 - 4*89
mp.dps=14417 - 4*89 #m* n -1
text=str(mp.pi)
margin = 1.27

Expand All @@ -20,25 +21,26 @@
# Add paragraphs with different font sizes and colors
p= doc.add_paragraph()

for i in range(len(text)):
for i in range(len(font_colors)):
digit = text[i]
color = font_colors[i]
run = p.add_run(digit)
run.font.color.rgb = RGBColor(color[0], color[1], color[2])
run.font.size = font_size

# Add credits if you want (appreciated but not necessary)
credits = "source code: https://github.com/annieqqa/happyPiDay"
q= doc.add_paragraph()
run = q.add_run(credits)
run.font.size = font_size
# Add credits to the footer
credits = "Source code: https://github.com/annieqqa/happyPiDay\nImage source: https://www.vecteezy.com/free-vector/happy-pi-day"
section = doc.sections[0]
footer = section.footer
footer_para = footer.paragraphs[0]
footer_para.text = credits

sections = doc.sections
for section in sections:
section.top_margin = Cm(margin)
section.bottom_margin = Cm(margin)
section.left_margin = Cm(margin)
section.right_margin = Cm(margin)
# sections = doc.sections
# for section in sections:
section.top_margin = Cm(margin)
section.bottom_margin = Cm(margin)
section.left_margin = Cm(margin)
section.right_margin = Cm(margin)

# Save the Word document
doc.save("output/HappyPiDay.docx")
Expand Down
2 changes: 1 addition & 1 deletion code/process_img.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PIL import Image, ImageDraw
image = Image.open('img/pi_img.jpg') #size 817*980
m = 162
n = 89
n = 89-4

width, height = image.size
pixels = image.getdata()
Expand Down
Binary file removed example_output.docx
Binary file not shown.
Binary file modified output/HappyPiDay.docx
Binary file not shown.

0 comments on commit 6031c3e

Please sign in to comment.