Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Add a new entry to the illumination settings, merging entries as
- # necessary.
- def onAdd(start, stop):
- # Go through our list of sequences and see if we need to merge them
- # together.
- sequence.append([start, stop])
- indexToDelete = len(sequence) - 1
- didChange = True
- while didChange:
- print sequence, indexToDelete
- didChange = False
- for i, (altStart, altStop) in enumerate(sequence):
- # Check for overlap.
- if ((start < altStart and stop > altStart) or
- (stop > altStop and start < altStop)):
- # Merge the two entries.
- start = min(start, altStart)
- stop = max(stop, altStop)
- sequence[i] = [start, stop]
- didChange = True
- if indexToDelete is not None:
- # Destroy the old sequence as it's been merged with
- # this one.
- del sequence[indexToDelete]
- indexToDelete = i
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement