Commit 618f2716 authored by Nathan/Eilisha Shiraini's avatar Nathan/Eilisha Shiraini
Browse files

Implemented the layout of the reference grid

parent 75ca18b3
......@@ -121,23 +121,33 @@ def modeMessage(layers, compact, wordcount):
def layoutModeMessage(matrix, message, layers, compact):
size = ps.matrixSize(layers, compact)
centerPos = size // 2
centerPos = size >> 1
layout = [(pos[0] + centerPos, pos[1] + centerPos) for pos in (MODE_LAYOUT_COMPACT if compact else MODE_LAYOUT_FULL)]
for i, bit in enumerate(message):
matrix[layout[i]] = bit
def layoutFinder(matrix, layers, compact):
size = ps.matrixSize(layers, compact)
centerPos = size // 2
centerPos = size >> 1
finderSize = 4 if compact else 6
for i in range(finderSize):
for j in range(finderSize):
matrix[i + centerPos, j + centerPos] = max(i, j) % 2 == 0
matrix[i + centerPos, j + centerPos] = max(i, j) & 1 == 0
def layoutOrientation(matrix, layers, compact):
size = ps.matrixSize(layers, compact)
centerPos = size // 2
centerPos = size >> 1
layout = ORIENTATION_LAYOUT_COMPACT if compact else ORIENTATION_LAYOUT_FULL
for y, x, v in layout:
matrix[y + centerPos, x + centerPos] = v
def layoutRefGrid(matrix, layers):
size= ps.matrixSize(layers, False)
centerPos = size >> 1
for i in range(0, centerPos, 16):
for j in range(-centerPos, centerPos):
matrix[centerPos + i, centerPos + j] = abs(j) & 1 == 0
matrix[centerPos - i, centerPos + j] = abs(j) & 1 == 0
matrix[centerPos + j, centerPos + i] = abs(j) & 1 == 0
matrix[centerPos + j, centerPos - i] = abs(j) & 1 == 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment