Animatable Editor¶
examples/editor.py
from keyed import AnimationType, Code, Scene, tokenize
from keyed_extras import Editor
scene = Scene(width=800, height=600, num_frames=120)
# Create the code object
filename = "examples/blur_example.py"
with open(filename, "r") as f:
content = f.read()
styled_tokens = tokenize(content, filename=filename)
code = Code(scene, styled_tokens, font_size=36, x=0, y=0, alpha=1)
# Create the Editor
editor = Editor(scene=scene, title=filename).scale(0.3).center()
editor.align_to(editor)
# Add the code to the editor
editor.add(code)
# Resize and scroll the editor
(
editor.resize(height=600)
.resize(height=1400, start=0, end=24)
.scroll_to(1, 36, 60)
.scroll_to(0, 72, 86)
.resize(height=-300, start=100, end=112, animation_type=AnimationType.ADD)
)
scene.add(editor)