forked from bedohswe/p3he
Add missing files.
This commit is contained in:
parent
14c7100b4c
commit
7000cfa685
1
maps/cross.json
Normal file
1
maps/cross.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"__type__": "objSegment", "isFinite": false, "pointA": {"__type__": "complex", "real": 1.0, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.0}, "color": [255, 0, 0]}, {"__type__": "objSegment", "isFinite": false, "pointA": {"__type__": "complex", "real": 0.0, "imag": 1.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.0}, "color": [0, 255, 0]}]
|
1
maps/empty.json
Normal file
1
maps/empty.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.0, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.0}, "color": [0, 0, 0]}]
|
1
maps/squareroom.json
Normal file
1
maps/squareroom.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.6}, "color": [255, 0, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": -0.6}, "color": [0, 255, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": -0.6}, "color": [0, 0, 255]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.6, "imag": 0.0}, "pointB": {"__type__": "complex", "real": 0.0, "imag": 0.6}, "color": [255, 255, 0]}]
|
1
maps/triangle.json
Normal file
1
maps/triangle.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": 0.38529100476842437, "imag": 0.0}, "pointB": {"__type__": "complex", "real": -0.2372040619364459, "imag": 0.36629343026935063}, "color": [255, 0, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.2372040619364459, "imag": 0.36629343026935063}, "pointB": {"__type__": "complex", "real": -0.22354939429564802, "imag": -0.26820653903460523}, "color": [0, 255, 0]}, {"__type__": "objSegment", "isFinite": true, "pointA": {"__type__": "complex", "real": -0.22354939429564802, "imag": -0.26820653903460523}, "pointB": {"__type__": "complex", "real": 0.39868528559672944, "imag": 0.017873216691274733}, "color": [0, 0, 255]}]
|
18
serialize.py
Normal file
18
serialize.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import levels
|
||||||
|
|
||||||
|
def object_hook(dct):
|
||||||
|
if '__type__' not in dct:
|
||||||
|
return dct
|
||||||
|
if dct['__type__'] == 'complex':
|
||||||
|
return complex(dct['real'], dct['imag'])
|
||||||
|
if dct['__type__'] == 'objSegment':
|
||||||
|
return levels.Segment(dct['isFinite'], dct['pointA'], dct['pointB'], tuple(dct['color']))
|
||||||
|
return dct
|
||||||
|
|
||||||
|
def default(obj):
|
||||||
|
if isinstance(obj, complex):
|
||||||
|
return {"__type__": "complex", "real": obj.real, "imag": obj.imag}
|
||||||
|
elif isinstance(obj, levels.Segment):
|
||||||
|
return {"__type__": "objSegment", "isFinite": obj.isFinite, "pointA": obj.pointA, "pointB": obj.pointB, "color": obj.color}
|
||||||
|
else:
|
||||||
|
raise TypeError("This type is not JSON serializable.")
|
Loading…
Reference in New Issue
Block a user