-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
185 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,7 @@ | |
"codeowners": [ | ||
"deblockt" | ||
], | ||
"requirements": [] | ||
"requirements": [ | ||
"drawSvg==1.6.0" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import base64 | ||
import struct | ||
import drawSvg as draw | ||
|
||
def build_map(m, track, file_path): | ||
inp = base64.b64decode(m) | ||
d = struct.unpack('<' + 'B' * (len(inp)), inp) | ||
full = [['.' for i in range(100)] for j in range(110)] | ||
akt = 0 | ||
i = 0 | ||
|
||
def placebyte(by): | ||
pair = by | ||
if pair & 0b10 == 0b10: | ||
full[((akt + 3) // 100)][((akt + 3) % 100)] = '_' | ||
elif pair & 0b01 == 0b01: | ||
full[((akt + 3) // 100)][((akt + 3) % 100)] = '0' | ||
pair = by >> 2 | ||
if pair & 0b10 == 0b10: | ||
full[((akt + 2) // 100)][((akt + 2) % 100)] = '_' | ||
elif pair & 0b01 == 0b01: | ||
full[((akt + 2) // 100)][((akt + 2) % 100)] = '0' | ||
pair = by >> 4 | ||
if pair & 0b10 == 0b10: | ||
full[((akt + 1) // 100)][((akt + 1) % 100)] = '_' | ||
elif pair & 0b01 == 0b01: | ||
full[((akt + 1) // 100)][((akt + 1) % 100)] = '0' | ||
pair = by >> 6 | ||
if pair & 0b10 == 0b10: | ||
full[(akt // 100)][(akt % 100)] = '_' | ||
elif pair & 0b01 == 0b01: | ||
full[(akt // 100)][(akt % 100)] = '0' | ||
|
||
while i < len(d): | ||
if i >= 9: | ||
if d[i] & 0b11000000 == 0b11000000: | ||
mul = d[i] & 0b00111111 | ||
if d[i + 1] & 0b11000000 == 0b11000000: | ||
i += 1 | ||
mul <<= 6 | ||
mul |= (d[i] & 0b00111111) | ||
for rep in range(mul): | ||
placebyte(d[i + 1]) | ||
akt += 4 | ||
i += 1 | ||
else: | ||
placebyte(d[i]) | ||
akt = akt + 4 | ||
i += 1 | ||
|
||
# print("\n".join(["".join(map(str,fline)) for fline in full])) | ||
|
||
wallx = [] | ||
wally = [] | ||
floorx = [] | ||
floory = [] | ||
for idy,l in enumerate(full): | ||
for idx,r in enumerate(l): | ||
if r == '0': | ||
wallx.append(idx) | ||
wally.append(idy) | ||
if r == '_': | ||
floorx.append(idx) | ||
floory.append(idy) | ||
|
||
inp = base64.b64decode(track) | ||
path = struct.unpack('<' + 'b'*(len(inp)-4), inp[4:]) | ||
|
||
d = draw.Drawing(500, 550) | ||
for i in range(len(wallx)): | ||
d.append(draw.Rectangle(wallx[i] * 5, 500 - (wally[i] * 5), 5, 5, fill='#000000', fill_opacity=0.7)) | ||
|
||
for i in range(len(floorx)): | ||
d.append(draw.Rectangle(floorx[i] * 5, 500 - (floory[i] * 5), 5, 5, fill='#000000', fill_opacity=0.3)) | ||
|
||
draw_path = [((coord * 5) + 2.5 if i % 2 == 0 else (500 - (coord * 5)) + 2.5) for i, coord in enumerate(path)] | ||
d.append(draw.Lines(*draw_path, fill="white", fill_opacity=0, stroke = 'black', stroke_opacity = 0.8)) | ||
|
||
d.saveSvg(file_path) | ||
|
||
#m = "AAAAAAAAZABkwvIAFUDXABXCVUDVABaqwlXVAFbCqqlA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NjQkNCQzIDMgMhoyGjEZMRkwGDAXLxctFy4XLBgqGCYZJhgmGCUZJRkkGiQcIhwbGhsaGhsYGxUaFBoSGRIYEBgRFxAWERcRFhIWExcTExMTEg4SDg4PDg8JFAkUChoKHAwdDB0OHg4eDx8PHxAfDx8QIBAhDiENIw0hDSEOIg0oDScNKA0oGCkYKRkqGSoaKxorGywbKxwqHCodKx0qHSoeKx4qHiohKiAqISshKyIqIisjKyQtJCwlLCgtKCwoLCkxKTEqMioyKzQrNCw1LDQsNSw1KzUsNCw0LzUvNTA2MDYyNzM3Nw==" | ||
|
||
#build_map(m, track, 'map.svg') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.