diff --git a/BeaufortQRCode.py b/BeaufortQRCode.py new file mode 100644 index 0000000..f5bc592 --- /dev/null +++ b/BeaufortQRCode.py @@ -0,0 +1,62 @@ +import io +import math +# Importing Image and ImageFont, ImageDraw module from PIL package +from PIL import Image, ImageFont, ImageDraw +#import QRcode generator lib +import qrcode + +#set the text and the code here +text = "█SLHJD!■C■KOQFHY■PKJSOOFH■BY■ONDTTX■GRC■ADLYJ■ZBSH■SOITRM●JKUHSOK●ZA■MAOLH■RVHRPJ!■█" +code = "TCHERNOBYL" #3💪+1👒+2👕+1🧥+1🧣+1🔫+4👂=🤠+❓TCHERNOBYL + +textsize = 30 #px + +#generate QRCode +qr = qrcode.QRCode( + version=1, #smallest + error_correction=qrcode.constants.ERROR_CORRECT_L, + box_size=10, + border=0, +) +qr.add_data(code) + +#saving the normal QRCode image +img = qr.make_image() +type(img) # qrcode.image.pil.PilImage +img.save("qrcode.png") + +#storing the qrCode in a list[list[bool]] +boolmatrix = qr.get_matrix() + +# creating a image object +codeximage = Image.new("RGB", (textsize*len(boolmatrix), textsize*len(boolmatrix)), "white") +codexdraw = ImageDraw.Draw(codeximage) + +# specified font size +fontnormal = ImageFont.truetype(r'./FiraMono_Regular.otf', textsize) +fontbold = ImageFont.truetype(r'./FiraMono_Bold.otf', textsize) + +# drawing text +index = 0 +for i, inner_list in enumerate(boolmatrix): + for j, element in enumerate(inner_list): + # get the letter in the text + letter = text[index%len(text)] + # set the font and the color according to the QRCode cell bool value + if(element): + font=fontbold + color="black" + else: + font=fontnormal + color="white" if (letter == '█') else "grey" + # drawing a box if the letter is █ + if (letter == '█'): + codexdraw.rectangle([(j*textsize, i*textsize), (j*textsize+textsize, i*textsize+textsize)] , fill =color) + # drawing the letter + else: + codexdraw.multiline_text((j*textsize+textsize/5, i*textsize-textsize/10), letter, fill =color, font =font, spacing=0, align ="left") + + index+=1 + +#saving the codex QRCode image with the text in the cells +codeximage.save("codex.png") \ No newline at end of file diff --git a/FiraMono_Bold.otf b/FiraMono_Bold.otf new file mode 100644 index 0000000..4ad726a Binary files /dev/null and b/FiraMono_Bold.otf differ diff --git a/FiraMono_Medium.otf b/FiraMono_Medium.otf new file mode 100644 index 0000000..4f208e9 Binary files /dev/null and b/FiraMono_Medium.otf differ diff --git a/FiraMono_Regular.otf b/FiraMono_Regular.otf new file mode 100644 index 0000000..c30b25b Binary files /dev/null and b/FiraMono_Regular.otf differ diff --git a/codex.png b/codex.png new file mode 100644 index 0000000..bb7c35e Binary files /dev/null and b/codex.png differ diff --git a/codex1.png b/codex1.png new file mode 100644 index 0000000..509cf1d Binary files /dev/null and b/codex1.png differ diff --git a/qrcode.png b/qrcode.png new file mode 100644 index 0000000..9c08ee8 Binary files /dev/null and b/qrcode.png differ diff --git a/qrcodeIndice.png b/qrcodeIndice.png new file mode 100644 index 0000000..a6798bc Binary files /dev/null and b/qrcodeIndice.png differ