Illusion

Posted by Junjie Hua on May 2, 2019

rotsnake

cafe wall illusin

python program

source: http://nekomosyakushimo.hatenablog.com/entry/2017/09/06/012510

#coding:utf-8
from __future__ import division
from __future__ import unicode_literals
from numpy import array
from PIL import Image, ImageDraw

#黒の四角の位置情報
black1 = array(range(5)) * 120 + 30

#描画オブジェクトとか
image = Image.new("RGB", (620,123), color=(255,255,255))
draw = ImageDraw.Draw(image)

for i in range(5): #上段の四角形を描く
    draw.rectangle(((black1[i],0),(black1[i]+60,60)), outline = None, fill = (0,0,0))
for j in range(5): #下段の四角形を描く
    draw.rectangle(((black1[j]+30,63),(black1[j]+90,123)), outline = None, fill = (0,0,0))
draw.line([(0,61),(620,61)], width = 2, fill = (128,128,128)) #真ん中の灰色の線

image.save("cafe.png")