Commit 75ca18b3 authored by Nathan/Eilisha Shiraini's avatar Nathan/Eilisha Shiraini
Browse files

Implemented generation of the orientation pattern

parent 1f732f58
......@@ -77,16 +77,46 @@ MODE_LAYOUT_COMPACT = [
(-3, -5),
]
ORIENTATION_LAYOUT_COMPACT = [
(-5, -5, True),
(-5, -4, True),
(-4, -5, True),
(-5, 5, True),
(-5, 4, False),
(-4, 5, True),
(5, -5, False),
(5, -4, False),
(4, -5, False),
(5, 5, False),
(5, 4, False),
(4, 5, True),
]
ORIENTATION_LAYOUT_FULL = [
(-7, -7, True),
(-7, -6, True),
(-6, -7, True),
(-7, 7, True),
(-7, 6, False),
(-6, 7, True),
(7, -7, False),
(7, -6, False),
(6, -7, False),
(7, 7, False),
(7, 6, False),
(6, 7, True),
]
def modeMessage(layers, compact, wordcount):
if isinstance(wordcount, tuple):
wordcount = wordcount[0]
if compact:
mm = ((layers - 1) & 0x3) << 6 + ((wordcount - 1) & 0x3F)
message = ((layers - 1) & 0x3) << 6 + ((wordcount - 1) & 0x3F)
else:
mm = ((layers - 1) & 0x1F) << 11 + ((wordcount - 1) & 0x7FF)
mmwords = rs.towords(mm, sz.WORD_SIZE_FOR_LAYERS[0])
cc = sz.GALLOIS_FIELD_FOR_LAYERS[0].gen_rs_code(mmwords, 5 if compact else 6)
result = rs.fromwords(mmwords + cc, sz.WORD_SIZE_FOR_LAYERS[0])
message = ((layers - 1) & 0x1F) << 11 + ((wordcount - 1) & 0x7FF)
mmwords = rs.towords(message, sz.WORD_SIZE_FOR_LAYERS[0])
rsvalue = sz.GALLOIS_FIELD_FOR_LAYERS[0].gen_rs_code(mmwords, 5 if compact else 6)
result = rs.fromwords(mmwords + rsvalue, sz.WORD_SIZE_FOR_LAYERS[0])
return result
def layoutModeMessage(matrix, message, layers, compact):
......@@ -103,3 +133,11 @@ def layoutFinder(matrix, layers, compact):
for i in range(finderSize):
for j in range(finderSize):
matrix[i + centerPos, j + centerPos] = max(i, j) % 2 == 0
def layoutOrientation(matrix, layers, compact):
size = ps.matrixSize(layers, compact)
centerPos = size // 2
layout = ORIENTATION_LAYOUT_COMPACT if compact else ORIENTATION_LAYOUT_FULL
for y, x, v in layout:
matrix[y + centerPos, x + centerPos] = v
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