Spaces:
Running
on
L4
Running
on
L4
File size: 1,707 Bytes
c1ce505 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
from .project import DeepSVGProject
from ..config import STATE_PATH
import pickle
import os
class ToolMode:
MOVE = 0
PEN = 1
PENCIL = 2
PLAY = 3
class DrawMode:
STILL = 0
DRAW = 1
HOLDING_DOWN = 2
class LoopMode:
NORMAL = 0
REVERSE = 1
PINGPONG = 2
class PlaybackMode:
NORMAL = 0
EASE = 1
class LoopOrientation:
FORWARD = 1
BACKWARD = -1
class State:
def __init__(self):
self.project_file = None
self.project = DeepSVGProject()
self.loop_mode = LoopMode.PINGPONG
self.loop_orientation = LoopOrientation.FORWARD
self.playback_mode = PlaybackMode.EASE
self.delay = 1 / 10.
self.modified = False
# Keep track of previously selected current_frame, separately from timeline's selected_frame attribute
self.current_frame = -1
self.current_path = None
self.draw_mode = DrawMode.STILL
self.clipboard = None
# UI references
self.main_widget = None
self.header = None
self.sidebar = None
self.draw_viewbox = None
self.timeline = None
def save_state(self):
with open(STATE_PATH, "wb") as f:
state_dict = {k: v for k, v in self.__dict__.items() if k in ["project_file"]}
pickle.dump(state_dict, f)
def load_state(self):
if os.path.exists(STATE_PATH):
with open(STATE_PATH, "rb") as f:
self.__dict__.update(pickle.load(f))
def load_project(self):
if self.project_file is not None:
self.project.load_project(self.project_file)
else:
self.project_file = self.project.filename
|