Created
June 21, 2019 09:17
-
-
Save ten986/e3647ccfd2458325d70216ee4e2a21f1 to your computer and use it in GitHub Desktop.
befunge93のコードをpicfungeに変換するコード。スタックを使いすぎたりするとバグる。
This file contains 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
from PIL import Image, ImageDraw, ImageFont | |
import sys | |
im = Image.new("RGB", (512, 512), (0, 0, 0)) | |
draw = ImageDraw.Draw(im) | |
lines = sys.stdin.readlines() | |
maxi = 0 | |
maxj = 0 | |
for i, line in enumerate(lines): | |
line = line.strip("\n") | |
if i > maxi: | |
maxi = i | |
for j, c in enumerate(line): | |
draw.point((j, i), fill=(0 if i != 0 or j !=0 else ord("A") , ord(c), 0)) | |
if j > maxj: | |
maxj = j | |
im = im.crop((0,0,maxj+1,maxi+1)) | |
im.save('out.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment