Browse Source

feat: load data from yaml file

legacy
Dnomd343 2 years ago
parent
commit
1cb07f4bd3
  1. 172
      svg-demo/demo.yml
  2. 57
      svg-demo/svg_dump.py

172
svg-demo/demo.yml

@ -0,0 +1,172 @@
layer:
- ["603EDF5CAFFF5E2"] # layer 0
- ["61BEC75CAFFF5E2","0C3EDF5CAFFF5E2"] # layer 1
- ["0DBEC75CAFFF5E2","EC34DF1CAFFF5E2"] # layer 2
- ["EDB4C71CAFFF5E2","EC34DFE42FFF5E2"] # layer 3
- ["EDB4C7E42FFF5E2"] # layer 4
- ["EDB4F8E50FFF5E2"] # layer 5
- ["ED84FBE50FFF5E2"] # layer 6
- ["EC34FBE50FFF5E2"] # layer 7
- ["EFB4D3E40FFF5E2"] # layer 8
- ["EFB4D3039FFF5E2"] # layer 9
- ["EFB413639FFF5E2"] # layer 10
- ["E3B4136F9FFF5E2"] # layer 11
- ["FC34836F9FFF5E2"] # layer 12
- ["FDB4806F9FFF5E2"] # layer 13
- ["FDB4B96C0FFF5E2"] # layer 14
- ["FDB4B9603FFF5E2"] # layer 15
- ["FDB4B901BFFF5E2"] # layer 16
- ["E1B5F909BFFF5E2","1DBEB941BFFF5E2"] # layer 17
- ["01BFF949BFFF5E2"] # layer 18
- ["603FF949BFFF5E2"] # layer 19
- ["6C0FF949BFFF5E2"] # layer 20
- ["6F9FC049BFFF5E2"] # layer 21
- ["6F9FC3483FFF5E2"] # layer 22
- ["6F9E3B413FFF5E2"] # layer 23
- ["6F91FB093FFF5E2"] # layer 24
- ["6F9FFB4931FF1E2"] # layer 25
- ["6F9FFB493FC7F02"] # layer 26
- ["6F9FFB493FF8F10"] # layer 27
- ["6F9FFB490FF8F13"] # layer 28
- ["6F9FF8490FFBF13"] # layer 29
- ["6F9FC7482FFBF13"] # layer 30
- ["6F9FFF492FC3F03"] # layer 31
- ["6F9FFF4921FB1E3"] # layer 32
- ["6F91FF092FFB5E3"] # layer 33
- ["6F9E3F412FFB5E3"] # layer 34
- ["639E3F4D2FFB5E3"] # layer 35
- ["039EFF4D2FFB5E3"] # layer 36
- ["E40EFF4D2FFB5E3"] # layer 37
- ["E47EFA4D0FFB5E3","E78ED74C2FFB5E3"] # layer 38
- ["E7FED24C0FFB5E3"] # layer 39
- ["E7FED2403FFB5E3"] # layer 40
- ["E7FED25FBFE3403"] # layer 41
- ["E7FED25FBFE34C0"] # layer 42
- ["E7FED25FBFE04D8"] # layer 43
- ["E7FED25F8FE04DB"] # layer 44
- ["E78ED05FFFE24DB"] # layer 45
- ["E47EC25FFFE24DB"] # layer 46
- ["E5FE025FFFE24DB"] # layer 47
- ["E5FFFA5E7E024DB"] # layer 48
- ["E5FFFA5E7E1A41B"] # layer 49
- ["E5FFFA5E71DA09B"] # layer 50
- ["E5F1FA1E7FDA49B"] # layer 51
- ["E5FFC2F07FDA49B"] # layer 52
- ["E5FFC2F1FFC249B"] # layer 53
- ["E5FFC2F1FFDA483"] # layer 54
- ["E5FFC2F1FFDA498"] # layer 55
- ["E5FFC2F18FDF49A"] # layer 56
- ["E58FC7F1AFDF49A"] # layer 57
- ["E43FC7F1AFDF49A"] # layer 58
- ["E5BFC7F02FDF49A"] # layer 59
- ["E5B1FF1E2FDF49A"] # layer 60
- ["E5BFFF5E21DF09A"] # layer 61
- ["E5BFFF5E2E1F41A"] # layer 62
- ["E5BFFF5E2E1F4C2","E5BFFF5E2EDF402"] # layer 63
- ["E5BFFF5E2EC74C2"] # layer 64
- ["E5BFFF5E2EF84D0"] # layer 65
- ["E5BFF85E0EFF4D2"] # layer 66
- ["E5BE3F43CEFF4D2"] # layer 67
- ["E5BEFF43CE3F4D2"] # layer 68
- ["E5BEFF4FCE3F412"] # layer 69
- ["E5BEFF4FC1FF092"] # layer 70
- ["E5B0FF0FCFFF492"] # layer 71
- ["E5B03F6FCFFF492"] # layer 72
- ["01BE7F6FCFFF492"] # layer 73
- ["603E7F6FCFFF492"] # layer 74
- ["6C0E7F6FCFFF492"] # layer 75
- ["6FFE7C6C0FFF492"] # layer 76
- ["6FFE7C603FFF492"] # layer 77
- ["6FFE7C01BFFF492"] # layer 78
- ["6FF03CE5BFFF492"] # layer 79
- ["63F63CE5BFFF492"] # layer 80
- ["7F87E0E5BFFF492"] # layer 81
next:
- - [0,1] # (0, 0) -> 1
- - [0] # (1, 0) -> 2
- [0,1] # (1, 1) -> 2
- - [0] # (2, 0) -> 3
- [0,1] # (2, 1) -> 3
- - [0] # (3, 0) -> 4
- [0] # (3, 1) -> 4
- - [0] # (4, 0) -> 5
- - [0] # (5, 0) -> 6
- - [0] # (6, 0) -> 7
- - [0] # (7, 0) -> 8
- - [0] # (8, 0) -> 9
- - [0] # (9, 0) -> 10
- - [0] # (10, 0) -> 11
- - [0] # (11, 0) -> 12
- - [0] # (12, 0) -> 13
- - [0] # (13, 0) -> 14
- - [0] # (14, 0) -> 15
- - [0] # (15, 0) -> 16
- - [0,1] # (16, 0) -> 17
- - [0] # (17, 0) -> 18
- [0] # (17, 1) -> 18
- - [0] # (18, 0) -> 19
- - [0] # (19, 0) -> 20
- - [0] # (20, 0) -> 21
- - [0] # (21, 0) -> 22
- - [0] # (22, 0) -> 23
- - [0] # (23, 0) -> 24
- - [0] # (24, 0) -> 25
- - [0] # (25, 0) -> 26
- - [0] # (26, 0) -> 27
- - [0] # (27, 0) -> 28
- - [0] # (28, 0) -> 29
- - [0] # (29, 0) -> 30
- - [0] # (30, 0) -> 31
- - [0] # (31, 0) -> 32
- - [0] # (32, 0) -> 33
- - [0] # (33, 0) -> 34
- - [0] # (34, 0) -> 35
- - [0] # (35, 0) -> 36
- - [0] # (36, 0) -> 37
- - [0,1] # (37, 0) -> 38
- - [0] # (38, 0) -> 39
- [0] # (38, 1) -> 39
- - [0] # (39, 0) -> 40
- - [0] # (40, 0) -> 41
- - [0] # (41, 0) -> 42
- - [0] # (42, 0) -> 43
- - [0] # (43, 0) -> 44
- - [0] # (44, 0) -> 45
- - [0] # (45, 0) -> 46
- - [0] # (46, 0) -> 47
- - [0] # (47, 0) -> 48
- - [0] # (48, 0) -> 49
- - [0] # (49, 0) -> 50
- - [0] # (50, 0) -> 51
- - [0] # (51, 0) -> 52
- - [0] # (52, 0) -> 53
- - [0] # (53, 0) -> 54
- - [0] # (54, 0) -> 55
- - [0] # (55, 0) -> 56
- - [0] # (56, 0) -> 57
- - [0] # (57, 0) -> 58
- - [0] # (58, 0) -> 59
- - [0] # (59, 0) -> 60
- - [0] # (60, 0) -> 61
- - [0] # (61, 0) -> 62
- - [0,1] # (62, 0) -> 63
- - [0] # (63, 0) -> 64
- [0] # (63, 1) -> 64
- - [0] # (64, 0) -> 65
- - [0] # (65, 0) -> 66
- - [0] # (66, 0) -> 67
- - [0] # (67, 0) -> 68
- - [0] # (68, 0) -> 69
- - [0] # (69, 0) -> 70
- - [0] # (70, 0) -> 71
- - [0] # (71, 0) -> 72
- - [0] # (72, 0) -> 73
- - [0] # (73, 0) -> 74
- - [0] # (74, 0) -> 75
- - [0] # (75, 0) -> 76
- - [0] # (76, 0) -> 77
- - [0] # (77, 0) -> 78
- - [0] # (78, 0) -> 79
- - [0] # (79, 0) -> 80
- - [0] # (80, 0) -> 81

57
svg-demo/svg_dump.py

@ -1,6 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import yaml
CASE_WIDTH = 48
CASE_HEIGHT = 72
@ -12,36 +14,39 @@ MAIN_MARGIN_Y = 8
LINK_OFFSET = 1
layer = [
["603EDF5CAFFF5E2"], # layer 0
["61BEC75CAFFF5E2","0C3EDF5CAFFF5E2"], # layer 1
["0DBEC75CAFFF5E2","EC34DF1CAFFF5E2"], # layer 2
["EDB4C71CAFFF5E2","EC34DFE42FFF5E2"], # layer 3
["EDB4C7E42FFF5E2"], # layer 4
["EDB4F8E50FFF5E2"], # layer 5
]
link = [[
[0, 1] # (0, 0) -> 1
], [
[0], # (1, 0) -> 2
[0, 1] # (1, 1) -> 2
], [
[0], # (2, 0) -> 3
[0, 1], # (2, 1) -> 3
], [
[0], # (3, 0) -> 4
[0], # (3, 1) -> 4
], [
[0], # (4, 0) -> 5
]]
# layer = [
# ["603EDF5CAFFF5E2"], # layer 0
# ["61BEC75CAFFF5E2","0C3EDF5CAFFF5E2"], # layer 1
# ["0DBEC75CAFFF5E2","EC34DF1CAFFF5E2"], # layer 2
# ["EDB4C71CAFFF5E2","EC34DFE42FFF5E2"], # layer 3
# ["EDB4C7E42FFF5E2"], # layer 4
# ["EDB4F8E50FFF5E2"], # layer 5
# ]
#
# link = [[
# [0, 1] # (0, 0) -> 1
# ], [
# [0], # (1, 0) -> 2
# [0, 1] # (1, 1) -> 2
# ], [
# [0], # (2, 0) -> 3
# [0, 1], # (2, 1) -> 3
# ], [
# [0], # (3, 0) -> 4
# [0], # (3, 1) -> 4
# ], [
# [0], # (4, 0) -> 5
# ]]
raw_data = yaml.load(open('demo.yml').read(), Loader = yaml.FullLoader)
layer = raw_data['layer']
link = raw_data['next']
# print(layer)
# print(link)
MAX_CASE_X = 2
MAX_CASE_Y = 6
MAX_CASE_X = max([len(x)for x in layer])
MAX_CASE_Y = len(layer)
# def cal_length(num: int, single_length: int, distance: int):
# return num * single_length + (num - 1) * distance

Loading…
Cancel
Save