Created
May 27, 2022 06:19
-
-
Save emlazzarin/3ded63faa4b93d69cf216e1b95f04938 to your computer and use it in GitHub Desktop.
Implementation of Tupper's Formula in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from PIL import Image | |
def tupper( | |
x, | |
y, | |
k, | |
): | |
y = y + k | |
if 0.5 < (y // 17 // pow(2, 17 * x + y % 17)) % 2: | |
return (255, 255, 255) | |
else: | |
return (0, 0, 0) | |
def render(width, height, k, func): | |
image_array = [func(x, y, k) for x in range(width) for y in range(height)] | |
return np.reshape( | |
np.asarray(image_array, dtype=np.uint8), newshape=(width, height, 3) | |
) | |
out = render( | |
width=106, | |
height=17, | |
k=960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719, | |
func=tupper, | |
) | |
img = Image.fromarray(out, mode="RGB") | |
img.rotate(-90, expand=True).save("result.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment