1
0

まちがいさがし(pythonでAA)

Posted at

以下の「」の中、どれかが「」だよ、さがしてみよう。

ヒント:この画像は50x50文字。コードが読めれば見当がつくよ。

image.png

以下のコードで書きました

from PIL import Image, ImageDraw, ImageFont
import numpy as np

size = 50 # 画像サイズ
ofs_y = 55.0 / 256 # オフセット(フォントごとに異なる)
font = ImageFont.truetype('Koruri-Bold.ttf', size)

img = Image.new('1', (size, size), color='white')
draw = ImageDraw.Draw(img)
draw.text((0, -ofs_y * size), '', font=font, fill='black')

data = np.array(img)

i = 0
for stride in data:
    for bit in stride:
        i += 1
        print("" if i == 1467 else " " if bit else "", end= "")
    print("")
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0