Last active
August 23, 2021 17:06
-
-
Save meshula/127d59922f75028e7f17fe2c0e4b021d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class Marker { | |
| } | |
| class Element { | |
| var layers = [CGImage?]() // this will become an ImageIndex that refers to a jpg, tile, etc | |
| var markers = [Int]() | |
| var start_frame = Int(0) | |
| var end_frame_ex = Int(0) | |
| var in_frame = Int(0) | |
| var out_frame_ex = Int(0) | |
| } | |
| struct TrackIndex : Hashable { | |
| var i : Int | |
| } | |
| struct ElementIndex : Hashable { | |
| var i : Int | |
| } | |
| struct MarkerIndex : Hashable { | |
| var i : Int | |
| } | |
| @objc(Sequence) public | |
| class Sequence : NSObject { | |
| // elements and markers are concrete | |
| var elements = [ElementIndex : Element]() | |
| var markers = [MarkerIndex : Marker]() | |
| // the sequence structure is encoded in this graph | |
| var tracks = [TrackIndex : [ElementIndex]]() | |
| var markerToElement = [MarkerIndex : ElementIndex]() | |
| var elementToTrack = [ElementIndex : TrackIndex]() | |
| override init() {} | |
| // a stub to stand in for the real application | |
| func addNewBoardAndSketch(_ : Int?) {} | |
| // render the sequence into an interval tree | |
| // it's the composition as it existed at the time of iteration | |
| func sequence() -> AugmentedIntervalTree<Int, ElementIndex> { | |
| var r = AugmentedIntervalTree<Int, ElementIndex>() | |
| for (index, element) in elements { | |
| r.insert(Interval<Int, ElementIndex>(start: element.start_frame, | |
| end: element.end_frame_ex, | |
| data: index)) | |
| } | |
| return r | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment