-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.py
47 lines (37 loc) · 1.21 KB
/
lib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
import numpy as np
import collections
def connect_vertical_horizontal(matrix, pixel_src, pixel_dest):
"""
Connection of two pixels via vertical - horizontal connection. Pixel receives the color of the start pixel
:param matrix:
:param pixel_src:
:param pixel_dest:
:return: matrix_changed
"""
point_src = (pixel_src[1],pixel_src[0])
point_dest = (pixel_dest[1],pixel_dest[0])
row_src = point_src[0]
column_src = point_src[1]
row_dest = point_dest[0]
column_dest = point_dest[1]
color = matrix[row_src][column_src]
if row_src < row_dest:
#top-bottom
for i in range(row_src, row_dest + 1):
matrix[row_src][column_src] = color
row_src += 1
for j in range(column_src, column_dest - 1):
matrix[row_dest][column_src + 1] = color
column_src += 1
else:
#bottom-top
for i in range(row_dest, row_src + 1):
matrix[row_src][column_src] = color
row_src -= 1
for j in range(column_src, column_dest - 1):
matrix[row_dest][column_src + 1] = color
column_src += 1
return matrix
def dark_magic():
return