Overview
TheVSCodeMockup class creates a realistic Visual Studio Code interface simulation using Pygame. It provides a complete mockup window with title bar, line numbers, text editor area, and window controls, designed to capture realistic coding session videos.
Constructor
The width of the mockup window in pixels
The height of the mockup window in pixels
Example
Instance Attributes
Display Properties
The main Pygame display surface for rendering the mockup
The width of the mockup window
The height of the mockup window
The desktop background image (Windows XP wallpaper). Falls back to
None if the image fails to loadWindow Layout
Margin around the VSCode window from screen edges
Height of the title bar in pixels
Calculated width of the VSCode window (excluding margins)
Calculated height of the VSCode window (excluding margins)
Text Rendering
Font for code text (Cascadia Code at 14pt, or Consolas fallback)
Font for window title (Segoe UI at 12pt)
Vertical spacing between lines of code
Width of a single character in pixels
Left margin for code text (space for line numbers)
Text Buffer
List of lines in the editor buffer
Index of the current line being edited
Colors
RGB color for close button:
(232, 17, 35) (red)RGB color for minimize button:
(255, 185, 0) (yellow)RGB color for maximize button:
(0, 204, 0) (green)Methods
simulate_typing
The text content to type (usually source code)
OpenCV VideoWriter object to save frames
Delay in seconds between each character (typing speed)
This method handles Pygame events during simulation and will respect quit events to allow graceful termination.
Example
capture_frame
numpy.ndarray - BGR image array ready for video writing
Example
write_char
A single character to write. Use
'\n' for newlinesExample
draw_window_chrome
- Draws the desktop background (Windows XP wallpaper or solid color fallback)
- Adds a shadow effect behind the window
- Draws the main VSCode window with dark background
- Renders the title bar by calling
draw_title_bar()
Example
draw_title_bar
This method is typically called by
draw_window_chrome() and doesn’t need to be called directly.draw_window_buttons
Diameter of each circular button in pixels
Spacing between buttons in pixels
Vertical position of the button centers
This method is typically called by
draw_title_bar() and doesn’t need to be called directly.draw_line_numbers
Example
Color Constants
The following color constants are defined invscode_mockup.py:
| Constant | RGB Value | Description |
|---|---|---|
BACKGROUND | (30, 30, 30) | Dark background of VSCode editor |
TEXT_COLOR | (220, 220, 220) | Code text color |
LINE_NUMBER_COLOR | (100, 100, 100) | Line number color |
TITLE_BAR_COLOR | (50, 50, 50) | Title bar background |
DESKTOP_COLOR | (0, 122, 204) | Desktop background fallback |
Complete Usage Example
Dependencies
pygame- GUI and renderingcv2(OpenCV) - Video capture and encodingnumpy- Frame array manipulation