Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # was just curious how the patterns will appear
- import ctypes
- ctypes.windll.user32.SetProcessDPIAware()
- import cv2
- import numpy as np
- def step(canvas, x, y, iter):
- h, w, _ = canvas.shape
- if x < 0 or y < 0 or x >= w or y >= h or iter < 0:
- return
- canvas[y][x] *= 0
- for i in range(8):
- di = int(i/1%2)
- xs = int((int(i/2%2))*2 - 1)
- ys = int((int(i/4%2))*2 - 1)
- step(canvas, x+int(1+di)*xs, y+int(2-di)*ys, iter-1)
- canvas = np.ones((100, 100, 3))
- for i in range(5):
- step(canvas, 50, 50, i)
- canvas2 = cv2.resize(canvas, dsize=(0, 0), fx=4, fy=4, interpolation=cv2.INTER_NEAREST)
- cv2.imshow('image', canvas2)
- cv2.waitKey(1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement