aboutsummaryrefslogtreecommitdiff
path: root/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2018-12-06 00:24:03 +0100
committerGitHub <noreply@github.com>2018-12-06 00:24:03 +0100
commitc796729c5f1f0fdb68f26a16de1d4f164bb7d3d6 (patch)
tree6c7a6c476f5a55661deea945d00f6a8cc3842dd5 /src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
parente56c60e17f5060203c993c852272e795b3ee6224 (diff)
parentc3f8b0a72de4a8a11bf5c8a1895143a4f5fa16ee (diff)
downloadLuxcena-Neo-c796729c5f1f0fdb68f26a16de1d4f164bb7d3d6.tar.gz
Luxcena-Neo-c796729c5f1f0fdb68f26a16de1d4f164bb7d3d6.zip
Merge pull request #7 from JakobST1n/python
Python
Diffstat (limited to 'src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py')
-rw-r--r--src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
index 0986b45..320da02 100644
--- a/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
+++ b/src/compileAndRun/pythonSupportFiles/LuxcenaNeo/Matrix.py
@@ -22,21 +22,45 @@ def getSegmentRange(segments, n):
class Matrix:
def __init__(self, segments, matrix):
- self.matrix = []
+ self.matrix = [] # Holds the matrix
+ self.xLen = 0 # The width of the matrix
+ self.yLen = len(matrix) # The heigth of the matrix
+
for yPos in range(len(matrix)):
yVal = matrix[yPos]
thisY = []
for xPos in range(len(yVal)):
- if matrix[yPos][xPos][1] == True:
- thisY += reversed(getSegmentRange(segments, matrix[yPos][xPos][0]))
- else:
- thisY += getSegmentRange(segments, matrix[yPos][xPos][0])
+ # This gets the range of segment n
+ segmentRange = getSegmentRange(segments, matrix[yPos][xPos][0])
+
+ # This adds the range to the current row's list
+ # if in the config [<segment_num>, <reversed>]
+ # reversed == true, revese the list before adding it
+ thisY += reversed(segmentRange) if matrix[yPos][xPos][1] else segmentRange
+
+ # This just finds the longest row in the matrix
+ if (len(thisY) > self.xLen):
+ self.xLen = len(thisY)
+
self.matrix.append(thisY)
def get(self, x, y):
""" Return the value of a place in the matrix given x and y coordinates """
return self.matrix[y][x]
+
+ def dump(self):
+ nSpacers = (self.xLen*6) // 2 - 6
+ print( ("=" * nSpacers) + "Matrix dump" + ("=" * nSpacers) )
+
+ for y in self.matrix:
+ thisYLine = ""
+ for x in y:
+ thisYLine += ( ' ' * (5 - len(str(x))) ) + str(x) + ' '
+ print(thisYLine)
+
+ print("=" * (self.xLen*6))
+
if __name__ == "__main__":
testMatrix = Matrix(