Create a simulation widget for: {{conceptName}}
Concept Overview
{{conceptOverview}}
Key Points
{{keyPoints}}
Variables to Expose
{{variables}}
Design Idea
{{designIdea}}
Language
{{languageDirective}}
Generate a complete, interactive HTML simulation with these MANDATORY features:
Structure
- Embedded JSON config in
<script type="application/json" id="widget-config"> - Control panel with sliders for each variable
- Canvas visualization with proper sizing
- Preset buttons for common scenarios
Mobile Responsiveness (CRITICAL)
- Control panel MUST NOT overlap canvas on mobile
- Use
flex-col md:flex-rowlayout with proper spacing - Control panel:
max-h-[40vh] md:max-h-screenwith overflow scroll - Canvas container:
min-h-[300px]to ensure visibility - Touch-friendly controls (44px minimum touch targets)
Button Logic (CRITICAL)
- Main button MUST handle all states correctly:
- "启动" → Starts simulation
- "暂停" → Pauses running simulation
- "重新开始" → Resets to initial state, then starts fresh
- Reset function MUST reset ALL state variables (position, velocity, time, etc.)
- Use clear state tracking:
{ running: boolean, ended: boolean, paused: boolean }
Canvas
- Auto-resize on window resize
- Clear visualization with grid or guides
- Real-time data display overlay
- Proper scaling for different screen sizes
Interactivity
- Real-time updates when sliders change
- Presets apply and reset simulation
- Keyboard shortcuts (Space = toggle, R = reset)
- Touch gestures for mobile
Visual Polish
- Show current simulation state (running/paused/ended)
- Animate transitions
- Clear feedback when simulation ends
- High contrast colors for visibility