Tutorials & Guides¶
This section contains step-by-step tutorials and comprehensive guides for using CodeVideoRenderer.
Getting Started¶
Quick Start Guide¶
Create your first code animation video:
from CodeVideoRenderer import CameraFollowCursorCV
code = '''
def hello_world():
print("Hello, World!")
return True
'''
# Create a simple code animation
video = CameraFollowCursorCV(
code=('string', code),
language='python',
formatter_style='github-dark'
)
video.render()
Basic Concepts¶
Understanding CodeVideoRenderer¶
CodeVideoRenderer works by:
Parsing Code: Reads and processes your code
Syntax Highlighting: Applies language-specific coloring
Animation: Creates typing animations character by character
Camera Movement: Smoothly follows the cursor
Core Components¶
CameraFollowCursorCV: Main class for creating animations
Code Input: Support for strings and files
Renderer Types: Cairo (software) and OpenGL (hardware accelerated)
Intermediate Tutorials¶
Customizing Animation Speed¶
Control the typing speed with interval ranges:
video = CameraFollowCursorCV(
code=('string', 'your_code_here'),
language='python',
interval_range=(0.05, 0.1), # Fast typing
# interval_range=(0.2, 0.5), # Slow, deliberate typing
)
Working with Files¶
Animate code from existing files:
video = CameraFollowCursorCV(
code=('file', 'path/to/your/script.py'),
language='python',
video_name='MyScriptAnimation'
)
Advanced Tutorials¶
Custom Styling¶
Use different syntax highlighting styles:
# Available styles: github-dark, monokai, solarized-dark, etc.
video = CameraFollowCursorCV(
code=('string', 'code'),
language='python',
formatter_style='monokai'
)
Camera Configuration¶
Adjust camera behavior for different code sizes:
video = CameraFollowCursorCV(
code=('string', 'large_code_block'),
language='python',
camera_scale=0.3, # Zoom out for large files
line_spacing=1.2 # Increase spacing for readability
)
Best Practices¶
Code Preparation¶
Clean Code: Remove unnecessary comments and whitespace
Consistent Formatting: Use consistent indentation
Reasonable Length: Keep code blocks under 100 lines for optimal viewing
Performance Optimization¶
Use OpenGL: For faster rendering on supported systems
Batch Processing: Render multiple videos in sequence
Resolution: Choose appropriate resolution for your needs
Troubleshooting Common Issues¶
See the Reference Manual section for detailed API documentation and troubleshooting tips.