Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>FPS Math Formula Editor</title> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.js"></script> | |
| <style> | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| } | |
| :root { | |
| --bg-primary: #0a0e17; | |
| --bg-secondary: #111827; | |
| --bg-tertiary: #1f2937; | |
| --accent-primary: #00d4ff; | |
| --accent-secondary: #7c3aed; | |
| --accent-success: #10b981; | |
| --accent-warning: #f59e0b; | |
| --accent-danger: #ef4444; | |
| --text-primary: #f3f4f6; | |
| --text-secondary: #9ca3af; | |
| --border-color: #374151; | |
| --glow-cyan: 0 0 20px rgba(0, 212, 255, 0.3); | |
| --glow-purple: 0 0 20px rgba(124, 58, 237, 0.3); | |
| } | |
| body { | |
| font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | |
| background: var(--bg-primary); | |
| color: var(--text-primary); | |
| min-height: 100vh; | |
| overflow-x: hidden; | |
| } | |
| /* Animated Background */ | |
| .bg-animation { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| width: 100%; | |
| height: 100%; | |
| pointer-events: none; | |
| z-index: 0; | |
| overflow: hidden; | |
| } | |
| .bg-animation::before { | |
| content: ''; | |
| position: absolute; | |
| top: -50%; | |
| left: -50%; | |
| width: 200%; | |
| height: 200%; | |
| background: radial-gradient(circle at 20% 80%, rgba(0, 212, 255, 0.03) 0%, transparent 50%), | |
| radial-gradient(circle at 80% 20%, rgba(124, 58, 237, 0.03) 0%, transparent 50%); | |
| animation: bgPulse 15s ease-in-out infinite; | |
| } | |
| @keyframes bgPulse { | |
| 0%, 100% { transform: scale(1) rotate(0deg); } | |
| 50% { transform: scale(1.1) rotate(5deg); } | |
| } | |
| /* Header */ | |
| header { | |
| position: relative; | |
| z-index: 100; | |
| background: linear-gradient(180deg, rgba(17, 24, 39, 0.9) 0%, rgba(17, 24, 39, 0) 100%); | |
| padding: 1.5rem 2rem; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| border-bottom: 1px solid var(--border-color); | |
| } | |
| .logo { | |
| display: flex; | |
| align-items: center; | |
| gap: 1rem; | |
| } | |
| .logo-icon { | |
| width: 48px; | |
| height: 48px; | |
| background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); | |
| border-radius: 12px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| font-size: 1.5rem; | |
| box-shadow: var(--glow-cyan); | |
| animation: iconPulse 3s ease-in-out infinite; | |
| } | |
| @keyframes iconPulse { | |
| 0%, 100% { box-shadow: 0 0 20px rgba(0, 212, 255, 0.3); } | |
| 50% { box-shadow: 0 0 40px rgba(0, 212, 255, 0.5); } | |
| } | |
| .logo h1 { | |
| font-size: 1.5rem; | |
| font-weight: 700; | |
| background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary)); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| background-clip: text; | |
| } | |
| .logo span { | |
| font-size: 0.85rem; | |
| color: var(--text-secondary); | |
| } | |
| .header-actions { | |
| display: flex; | |
| gap: 1rem; | |
| align-items: center; | |
| } | |
| .anycoder-link { | |
| color: var(--text-secondary); | |
| text-decoration: none; | |
| font-size: 0.9rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| padding: 0.5rem 1rem; | |
| border-radius: 8px; | |
| transition: all 0.3s ease; | |
| border: 1px solid var(--border-color); | |
| } | |
| .anycoder-link:hover { | |
| color: var(--accent-primary); | |
| border-color: var(--accent-primary); | |
| box-shadow: var(--glow-cyan); | |
| } | |
| /* Main Container */ | |
| .container { | |
| position: relative; | |
| z-index: 10; | |
| max-width: 1600px; | |
| margin: 0 auto; | |
| padding: 2rem; | |
| } | |
| /* Stats Bar */ | |
| .stats-bar { | |
| display: grid; | |
| grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | |
| gap: 1rem; | |
| margin-bottom: 2rem; | |
| } | |
| .stat-card { | |
| background: var(--bg-secondary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 16px; | |
| padding: 1.25rem; | |
| position: relative; | |
| overflow: hidden; | |
| transition: all 0.3s ease; | |
| } | |
| .stat-card::before { | |
| content: ''; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| width: 4px; | |
| height: 100%; | |
| background: linear-gradient(180deg, var(--accent-primary), var(--accent-secondary)); | |
| } | |
| .stat-card:hover { | |
| transform: translateY(-2px); | |
| border-color: var(--accent-primary); | |
| box-shadow: var(--glow-cyan); | |
| } | |
| .stat-icon { | |
| width: 40px; | |
| height: 40px; | |
| background: rgba(0, 212, 255, 0.1); | |
| border-radius: 10px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| color: var(--accent-primary); | |
| font-size: 1.2rem; | |
| margin-bottom: 0.75rem; | |
| } | |
| .stat-value { | |
| font-size: 1.75rem; | |
| font-weight: 700; | |
| color: var(--text-primary); | |
| margin-bottom: 0.25rem; | |
| } | |
| .stat-label { | |
| font-size: 0.85rem; | |
| color: var(--text-secondary); | |
| } | |
| /* Main Editor Layout */ | |
| .editor-layout { | |
| display: grid; | |
| grid-template-columns: 300px 1fr 350px; | |
| gap: 1.5rem; | |
| } | |
| @media (max-width: 1200px) { | |
| .editor-layout { | |
| grid-template-columns: 1fr; | |
| } | |
| } | |
| /* Panel Styles */ | |
| .panel { | |
| background: var(--bg-secondary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 20px; | |
| overflow: hidden; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .panel-header { | |
| padding: 1.25rem 1.5rem; | |
| border-bottom: 1px solid var(--border-color); | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| background: linear-gradient(90deg, rgba(0, 212, 255, 0.05) 0%, transparent 100%); | |
| } | |
| .panel-title { | |
| font-size: 1rem; | |
| font-weight: 600; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.75rem; | |
| } | |
| .panel-title i { | |
| color: var(--accent-primary); | |
| } | |
| .panel-content { | |
| padding: 1.5rem; | |
| flex: 1; | |
| overflow-y: auto; | |
| } | |
| /* Formula Input */ | |
| .formula-input-container { | |
| margin-bottom: 1.5rem; | |
| } | |
| .formula-label { | |
| display: block; | |
| font-size: 0.85rem; | |
| color: var(--text-secondary); | |
| margin-bottom: 0.5rem; | |
| font-weight: 500; | |
| } | |
| .formula-input { | |
| width: 100%; | |
| background: var(--bg-tertiary); | |
| border: 2px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 1rem; | |
| color: var(--text-primary); | |
| font-family: 'Consolas', 'Monaco', monospace; | |
| font-size: 1rem; | |
| resize: vertical; | |
| min-height: 120px; | |
| transition: all 0.3s ease; | |
| } | |
| .formula-input:focus { | |
| outline: none; | |
| border-color: var(--accent-primary); | |
| box-shadow: 0 0 0 4px rgba(0, 212, 255, 0.1); | |
| } | |
| .formula-input::placeholder { | |
| color: var(--text-secondary); | |
| opacity: 0.5; | |
| } | |
| /* Rendered Output */ | |
| .output-container { | |
| background: var(--bg-primary); | |
| border: 2px solid var(--border-color); | |
| border-radius: 16px; | |
| padding: 2rem; | |
| min-height: 200px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| margin-bottom: 1.5rem; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .output-container::before { | |
| content: ''; | |
| position: absolute; | |
| inset: 0; | |
| background: linear-gradient(45deg, transparent 40%, rgba(0, 212, 255, 0.02) 50%, transparent 60%); | |
| animation: shimmer 3s infinite; | |
| } | |
| @keyframes shimmer { | |
| 0% { transform: translateX(-100%); } | |
| 100% { transform: translateX(100%); } | |
| } | |
| .output-container .katex { | |
| font-size: 1.5rem; | |
| } | |
| /* Buttons */ | |
| .btn { | |
| padding: 0.75rem 1.5rem; | |
| border-radius: 10px; | |
| font-size: 0.9rem; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| display: inline-flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| border: none; | |
| } | |
| .btn-primary { | |
| background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary)); | |
| color: white; | |
| box-shadow: var(--glow-cyan); | |
| } | |
| .btn-primary:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 0 30px rgba(0, 212, 255, 0.5); | |
| } | |
| .btn-secondary { | |
| background: var(--bg-tertiary); | |
| color: var(--text-primary); | |
| border: 1px solid var(--border-color); | |
| } | |
| .btn-secondary:hover { | |
| border-color: var(--accent-primary); | |
| color: var(--accent-primary); | |
| } | |
| .btn-sm { | |
| padding: 0.5rem 1rem; | |
| font-size: 0.8rem; | |
| } | |
| .btn-group { | |
| display: flex; | |
| gap: 0.75rem; | |
| flex-wrap: wrap; | |
| } | |
| /* Variables Panel */ | |
| .variable-item { | |
| background: var(--bg-tertiary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 1rem; | |
| margin-bottom: 0.75rem; | |
| transition: all 0.3s ease; | |
| } | |
| .variable-item:hover { | |
| border-color: var(--accent-primary); | |
| } | |
| .variable-header { | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| margin-bottom: 0.75rem; | |
| } | |
| .variable-name { | |
| font-family: 'Consolas', monospace; | |
| color: var(--accent-primary); | |
| font-weight: 600; | |
| } | |
| .variable-type { | |
| font-size: 0.75rem; | |
| padding: 0.25rem 0.5rem; | |
| background: rgba(124, 58, 237, 0.2); | |
| color: var(--accent-secondary); | |
| border-radius: 4px; | |
| } | |
| .variable-value { | |
| display: flex; | |
| gap: 0.5rem; | |
| } | |
| .variable-input { | |
| flex: 1; | |
| background: var(--bg-primary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 8px; | |
| padding: 0.5rem 0.75rem; | |
| color: var(--text-primary); | |
| font-size: 0.9rem; | |
| } | |
| .variable-input:focus { | |
| outline: none; | |
| border-color: var(--accent-primary); | |
| } | |
| /* Preset Formulas */ | |
| .preset-list { | |
| list-style: none; | |
| } | |
| .preset-item { | |
| background: var(--bg-tertiary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 1rem; | |
| margin-bottom: 0.75rem; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| } | |
| .preset-item:hover { | |
| border-color: var(--accent-primary); | |
| transform: translateX(4px); | |
| box-shadow: var(--glow-cyan); | |
| } | |
| .preset-name { | |
| font-weight: 600; | |
| margin-bottom: 0.5rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| } | |
| .preset-name i { | |
| color: var(--accent-warning); | |
| } | |
| .preset-formula { | |
| font-family: 'Consolas', monospace; | |
| font-size: 0.85rem; | |
| color: var(--text-secondary); | |
| white-space: nowrap; | |
| overflow: hidden; | |
| text-overflow: ellipsis; | |
| } | |
| /* History Panel */ | |
| .history-item { | |
| display: flex; | |
| align-items: center; | |
| gap: 1rem; | |
| padding: 0.75rem; | |
| border-radius: 10px; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| margin-bottom: 0.5rem; | |
| } | |
| .history-item:hover { | |
| background: var(--bg-tertiary); | |
| } | |
| .history-icon { | |
| width: 32px; | |
| height: 32px; | |
| background: rgba(0, 212, 255, 0.1); | |
| border-radius: 8px; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| color: var(--accent-primary); | |
| } | |
| .history-content { | |
| flex: 1; | |
| min-width: 0; | |
| } | |
| .history-formula { | |
| font-family: 'Consolas', monospace; | |
| font-size: 0.8rem; | |
| white-space: nowrap; | |
| overflow: hidden; | |
| text-overflow: ellipsis; | |
| } | |
| .history-time { | |
| font-size: 0.75rem; | |
| color: var(--text-secondary); | |
| } | |
| /* FPS Calculator Section */ | |
| .fps-calculator { | |
| background: linear-gradient(135deg, rgba(0, 212, 255, 0.05) 0%, rgba(124, 58, 237, 0.05) 100%); | |
| border: 1px solid var(--border-color); | |
| border-radius: 16px; | |
| padding: 1.5rem; | |
| margin-top: 1.5rem; | |
| } | |
| .fps-grid { | |
| display: grid; | |
| grid-template-columns: repeat(2, 1fr); | |
| gap: 1rem; | |
| margin-bottom: 1rem; | |
| } | |
| .fps-input-group { | |
| display: flex; | |
| flex-direction: column; | |
| gap: 0.5rem; | |
| } | |
| .fps-input-group label { | |
| font-size: 0.85rem; | |
| color: var(--text-secondary); | |
| } | |
| .fps-input { | |
| background: var(--bg-primary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 8px; | |
| padding: 0.75rem; | |
| color: var(--text-primary); | |
| font-size: 1rem; | |
| } | |
| .fps-input:focus { | |
| outline: none; | |
| border-color: var(--accent-primary); | |
| } | |
| /* Result Display */ | |
| .result-box { | |
| background: var(--bg-primary); | |
| border: 2px solid var(--accent-success); | |
| border-radius: 12px; | |
| padding: 1.5rem; | |
| text-align: center; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| .result-box::before { | |
| content: ''; | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| height: 3px; | |
| background: linear-gradient(90deg, var(--accent-success), var(--accent-primary)); | |
| } | |
| .result-value { | |
| font-size: 2.5rem; | |
| font-weight: 700; | |
| color: var(--accent-success); | |
| margin-bottom: 0.25rem; | |
| } | |
| .result-label { | |
| color: var(--text-secondary); | |
| font-size: 0.9rem; | |
| } | |
| /* Syntax Help */ | |
| .help-section { | |
| margin-top: 1.5rem; | |
| } | |
| .help-title { | |
| font-size: 0.9rem; | |
| font-weight: 600; | |
| margin-bottom: 1rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.5rem; | |
| color: var(--accent-warning); | |
| } | |
| .syntax-grid { | |
| display: grid; | |
| grid-template-columns: repeat(2, 1fr); | |
| gap: 0.5rem; | |
| } | |
| .syntax-item { | |
| background: var(--bg-tertiary); | |
| border-radius: 8px; | |
| padding: 0.5rem 0.75rem; | |
| font-size: 0.8rem; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| } | |
| .syntax-item code { | |
| color: var(--accent-primary); | |
| font-family: 'Consolas', monospace; | |
| } | |
| .syntax-desc { | |
| color: var(--text-secondary); | |
| } | |
| /* Tabs */ | |
| .tabs { | |
| display: flex; | |
| gap: 0.5rem; | |
| margin-bottom: 1rem; | |
| } | |
| .tab { | |
| padding: 0.5rem 1rem; | |
| border-radius: 8px; | |
| font-size: 0.85rem; | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| background: var(--bg-tertiary); | |
| color: var(--text-secondary); | |
| border: 1px solid transparent; | |
| } | |
| .tab.active { | |
| background: rgba(0, 212, 255, 0.1); | |
| color: var(--accent-primary); | |
| border-color: var(--accent-primary); | |
| } | |
| .tab:hover:not(.active) { | |
| border-color: var(--border-color); | |
| } | |
| /* Toast Notifications */ | |
| .toast-container { | |
| position: fixed; | |
| bottom: 2rem; | |
| right: 2rem; | |
| z-index: 1000; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 0.75rem; | |
| } | |
| .toast { | |
| background: var(--bg-secondary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 1rem 1.5rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 0.75rem; | |
| box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); | |
| animation: slideIn 0.3s ease; | |
| min-width: 300px; | |
| } | |
| @keyframes slideIn { | |
| from { | |
| transform: translateX(100%); | |
| opacity: 0; | |
| } | |
| to { | |
| transform: translateX(0); | |
| opacity: 1; | |
| } | |
| } | |
| .toast.success { | |
| border-left: 4px solid var(--accent-success); | |
| } | |
| .toast.error { | |
| border-left: 4px solid var(--accent-danger); | |
| } | |
| .toast.info { | |
| border-left: 4px solid var(--accent-primary); | |
| } | |
| .toast-icon { | |
| width: 24px; | |
| height: 24px; | |
| border-radius: 50%; | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| } | |
| .toast.success .toast-icon { | |
| background: rgba(16, 185, 129, 0.2); | |
| color: var(--accent-success); | |
| } | |
| .toast-message { | |
| flex: 1; | |
| font-size: 0.9rem; | |
| } | |
| /* Copy Button */ | |
| .copy-btn { | |
| position: absolute; | |
| top: 1rem; | |
| right: 1rem; | |
| background: var(--bg-tertiary); | |
| border: 1px solid var(--border-color); | |
| border-radius: 8px; | |
| padding: 0.5rem; | |
| color: var(--text-secondary); | |
| cursor: pointer; | |
| transition: all 0.3s ease; | |
| } | |
| .copy-btn:hover { | |
| color: var(--accent-primary); | |
| border-color: var(--accent-primary); | |
| } | |
| /* Responsive Adjustments */ | |
| @media (max-width: 768px) { | |
| header { | |
| flex-direction: column; | |
| gap: 1rem; | |
| padding: 1rem; | |
| } | |
| .container { | |
| padding: 1rem; | |
| } | |
| .stats-bar { | |
| grid-template-columns: repeat(2, 1fr); | |
| } | |
| .fps-grid { | |
| grid-template-columns: 1fr; | |
| } | |
| .syntax-grid { | |
| grid-template-columns: 1fr; | |
| } | |
| } | |
| /* Scrollbar Styling */ | |
| ::-webkit-scrollbar { | |
| width: 8px; | |
| height: 8px; | |
| } | |
| ::-webkit-scrollbar-track { | |
| background: var(--bg-primary); | |
| } | |
| ::-webkit-scrollbar-thumb { | |
| background: var(--border-color); | |
| border-radius: 4px; | |
| } | |
| ::-webkit-scrollbar-thumb:hover { | |
| background: var(--text-secondary); | |
| } | |
| /* Loading Animation */ | |
| .loading { | |
| display: inline-block; | |
| width: 20px; | |
| height: 20px; | |
| border: 2px solid rgba(255, 255, 255, 0.3); | |
| border-radius: 50%; | |
| border-top-color: var(--accent-primary); | |
| animation: spin 1s ease-in-out infinite; | |
| } | |
| @keyframes spin { | |
| to { transform: rotate(360deg); } | |
| } | |
| /* FPS Gauge Animation */ | |
| .fps-gauge { | |
| width: 150px; | |
| height: 75px; | |
| position: relative; | |
| margin: 0 auto 1rem; | |
| overflow: hidden; | |
| } | |
| .fps-gauge-bg { | |
| width: 150px; | |
| height: 150px; | |
| border-radius: 50%; | |
| background: conic-gradient( | |
| from 270deg, | |
| var(--accent-danger) 0deg 60deg, | |
| var(--accent-warning) 60deg 120deg, | |
| var(--accent-success) 120deg 180deg, | |
| var(--bg-tertiary) 180deg 360deg | |
| ); | |
| position: absolute; | |
| top: 0; | |
| } | |
| .fps-gauge-inner { | |
| width: 110px; | |
| height: 110px; | |
| background: var(--bg-primary); | |
| border-radius: 50%; | |
| position: absolute; | |
| top: 20px; | |
| left: 20px; | |
| display: flex; | |
| align-items: flex-end; | |
| justify-content: center; | |
| padding-bottom: 1rem; | |
| } | |
| .fps-gauge-needle { | |
| width: 4px; | |
| height: 50px; | |
| background: var(--text-primary); | |
| border-radius: 4px; | |
| transform-origin: bottom center; | |
| transform: rotate(-90deg); | |
| transition: transform 0.5s ease; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="bg-animation"></div> | |
| <header> | |
| <div class="logo"> | |
| <div class="logo-icon"> | |
| <i class="fas fa-calculator"></i> | |
| </div> | |
| <div> | |
| <h1>FPS Formula Editor</h1> | |
| <span>Mathematical Expression Renderer</span> | |
| </div> | |
| </div> | |
| <div class="header-actions"> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" class="anycoder-link" target="_blank"> | |
| <i class="fas fa-code"></i> | |
| Built with anycoder | |
| </a> | |
| <button class="btn btn-secondary btn-sm" onclick="exportFormulas()"> | |
| <i class="fas fa-download"></i> | |
| Export | |
| </button> | |
| <button class="btn btn-primary btn-sm" onclick="shareFormula()"> | |
| <i class="fas fa-share-alt"></i> | |
| Share | |
| </button> | |
| </div> | |
| </header> | |
| <div class="container"> | |
| <!-- Stats Bar --> | |
| <div class="stats-bar"> | |
| <div class="stat-card"> | |
| <div class="stat-icon"> | |
| <i class="fas fa-history"></i> | |
| </div> | |
| <div class="stat-value" id="historyCount">0</div> | |
| <div class="stat-label">Formula History</div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-icon"> | |
| <i class="fas fa-flask"></i> | |
| </div> | |
| <div class="stat-value" id="variableCount">0</div> | |
| <div class="stat-label">Active Variables</div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-icon"> | |
| <i class="fas fa-bolt"></i> | |
| </div> | |
| <div class="stat-value" id="evalCount">0</div> | |
| <div class="stat-label">Evaluations</div> | |
| </div> | |
| <div class="stat-card"> | |
| <div class="stat-icon"> | |
| <i class="fas fa-check-circle"></i> | |
| </div> | |
| <div class="stat-value" id="successRate">100%</div> | |
| <div class="stat-label">Success Rate</div> | |
| </div> | |
| </div> | |
| <!-- Main Editor Layout --> | |
| <div class="editor-layout"> | |
| <!-- Left Panel - Presets --> | |
| <div class="panel"> | |
| <div class="panel-header"> | |
| <span class="panel-title"> | |
| <i class="fas fa-book-open"></i> | |
| Preset Formulas | |
| </span> | |
| </div> | |
| <div class="panel-content"> | |
| <ul class="preset-list" id="presetList"> | |
| <!-- Presets will be populated by JS --> | |
| </ul> | |
| <div class="help-section"> | |
| <div class="help-title"> | |
| <i class="fas fa-code"></i> | |
| Quick Syntax | |
| </div> | |
| <div class="syntax-grid"> | |
| <div class="syntax-item"> | |
| <code>\frac{a}{b}</code> | |
| <span class="syntax-desc">Fraction</span> | |
| </div> | |
| <div class="syntax-item"> | |
| <code>\sqrt{x}</code> | |
| <span class="syntax-desc">Square Root</span> | |
| </div> | |
| <div class="syntax-item"> | |
| <code>x^n</code> | |
| <span class="syntax-desc">Power</span> | |
| </div> | |
| <div class="syntax-item"> | |
| <code>\sum</code> | |
| <span class="syntax-desc">Summation</span> | |
| </div> | |
| <div class="syntax-item"> | |
| <code>\int</code> | |
| <span class="syntax-desc">Integral</span> | |
| </div> | |
| <div class="syntax-item"> | |
| <code>\lim</code> | |
| <span class="syntax-desc">Limit</span> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Center Panel - Editor --> | |
| <div class="panel"> | |
| <div class="panel-header"> | |
| <span class="panel-title"> | |
| <i class="fas fa-edit"></i> | |
| Formula Editor | |
| </span> | |
| <div class="tabs"> | |
| <button class="tab active" data-tab="editor">Editor</button> | |
| <button class="tab" data-tab="fps">FPS Calc</button> | |
| </div> | |
| </div> | |
| <div class="panel-content"> | |
| <!-- Editor Tab --> | |
| <div id="editorTab"> | |
| <div class="formula-input-container"> | |
| <label class="formula-label">Enter your mathematical formula:</label> | |
| <textarea | |
| class="formula-input" | |
| id="formulaInput" | |
| placeholder="e.g., \frac{-b + \sqrt{b^2 - 4ac}}{2a}" | |
| >\frac{1}{f} = \frac{1}{v} + \frac{1}{u}</textarea> | |
| </div> | |
| <div style="position: relative;"> | |
| <div class="output-container" id="outputContainer"> | |
| <div id="renderedFormula"></div> | |
| </div> | |
| <button class="copy-btn" onclick="copyRendered()" title="Copy as LaTeX"> | |
| <i class="fas fa-copy"></i> | |
| </button> | |
| </div> | |
| <div class="btn-group"> | |
| <button class="btn btn-primary" onclick="renderFormula()"> | |
| <i class="fas fa-play"></i> | |
| Render Formula | |
| </button> | |
| <button class="btn btn-secondary" onclick="clearEditor()"> | |
| <i class="fas fa-trash"></i> | |
| Clear | |
| </button> | |
| <button class="btn btn-secondary" onclick="formatFormula()"> | |
| <i class="fas fa-align-left"></i> | |
| Format | |
| </button> | |
| </div> | |
| <!-- FPS Calculator --> | |
| <div class="fps-calculator"> | |
| <h3 style="margin-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem;"> | |
| <i class="fas fa-tachometer-alt" style="color: var(--accent-primary);"></i> | |
| FPS Calculator | |
| </h3> | |
| <div class="fps-grid"> | |
| <div class="fps-input-group"> | |
| <label>Frame Time (ms)</label> | |
| <input type="number" class="fps-input" id="frameTime" value="16.67" step="0.01"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>Target FPS</label> | |
| <input type="number" class="fps-input" id="targetFps" value="60" step="1"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>Render Time (ms)</label> | |
| <input type="number" class="fps-input" id="renderTime" value="8.33" step="0.01"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>Refresh Rate (Hz)</label> | |
| <input type="number" class="fps-input" id="refreshRate" value="144" step="1"> | |
| </div> | |
| </div> | |
| <div class="fps-grid"> | |
| <div class="result-box"> | |
| <div class="result-value" id="actualFps">60.00</div> | |
| <div class="result-label">Actual FPS</div> | |
| </div> | |
| <div class="result-box"> | |
| <div class="result-value" id="performanceScore">83%</div> | |
| <div class="result-label">Performance Score</div> | |
| </div> | |
| </div> | |
| <button class="btn btn-primary" style="width: 100%; margin-top: 1rem;" onclick="calculateFPS()"> | |
| <i class="fas fa-calculator"></i> | |
| Calculate | |
| </button> | |
| </div> | |
| </div> | |
| <!-- FPS Tab --> | |
| <div id="fpsTab" style="display: none;"> | |
| <div class="fps-calculator"> | |
| <h3 style="margin-bottom: 1rem;"> | |
| <i class="fas fa-chart-line" style="color: var(--accent-primary);"></i> | |
| Advanced FPS Analysis | |
| </h3> | |
| <div class="fps-gauge"> | |
| <div class="fps-gauge-bg"></div> | |
| <div class="fps-gauge-inner"> | |
| <div class="fps-gauge-needle" id="fpsNeedle"></div> | |
| </div> | |
| </div> | |
| <div class="fps-grid"> | |
| <div class="fps-input-group"> | |
| <label>Frame Time (ms)</label> | |
| <input type="number" class="fps-input" id="advFrameTime" value="16.67" step="0.01" onchange="advancedFPSCalc()"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>1% Low FPS</label> | |
| <input type="number" class="fps-input" id="lowFps" value="45" step="1" onchange="advancedFPSCalc()"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>0.1% Low FPS</label> | |
| <input type="number" class="fps-input" id="veryLowFps" value="30" step="1" onchange="advancedFPSCalc()"> | |
| </div> | |
| <div class="fps-input-group"> | |
| <label>Frame Variance (ms)</label> | |
| <input type="number" class="fps-input" id="frameVariance" value="2.5" step="0.1" onchange="advancedFPSCalc()"> | |
| </div> | |
| </div> | |
| <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin-top: 1rem;"> | |
| <div class="result-box"> | |
| <div class="result-value" id="avgFpsDisplay">60</div> | |
| <div class="result-label">Average FPS</div> | |
| </div> | |
| <div class="result-box"> | |
| <div class="result-value" id="frameBudget">6.67</div> | |
| <div class="result-label">Budget per Frame (ms)</div> | |
| </div> | |
| <div class="result-box"> | |
| <div class="result-value" id="overhead">2.0</div> | |
| <div class="result-label">Overhead Buffer (ms)</div> | |
| </div> | |
| <div class="result-box"> | |
| <div class="result-value" id="stabilityScore">95%</div> | |
| <div class="result-label">Stability Score</div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Right Panel - Variables & History --> | |
| <div class="panel"> | |
| <div class="panel-header"> | |
| <span class="panel-title"> | |
| <i class="fas fa-sliders-h"></i> | |
| Variables & History | |
| </span> | |
| </div> | |
| <div class="panel-content"> | |
| <!-- Variables Section --> | |
| <div id="variablesSection"> | |
| <h4 style="margin-bottom: 1rem; color: var(--text-secondary); font-size: 0.9rem;"> | |
| Detected Variables | |
| </h4> | |
| <div id="variablesList"> | |
| <div class="variable-item"> | |
| <div class="variable-header"> | |
| <span class="variable-name">a, b, c</span> | |
| <span class="variable-type">Auto-detected</span> | |
| </div> | |
| <div class="variable-value"> | |
| <input type="text" class="variable-input" placeholder="Values (e.g., 1, 2, 3)" id="varAbc"> | |
| </div> | |
| </div> | |
| </div> | |
| <button class="btn btn-secondary btn-sm" style="width: 100%;" onclick="evaluateFormula()"> | |
| <i class="fas fa-calculator"></i> | |
| Evaluate | |
| </button> | |
| <div id="evaluationResult" style="margin-top: 1rem; padding: 1rem; background: var(--bg-tertiary); border-radius: 12px; display: none;"> | |
| <div style="font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.5rem;">Result:</div> | |
| <div id="resultValue" style="font-size: 1.5rem; font-weight: 700; color: var(--accent-success);"></div> | |
| </div> | |
| </div> | |
| <!-- History Section --> | |
| <div style="margin-top: 2rem; border-top: 1px solid var(--border-color); padding-top: 1.5rem;"> | |
| <h4 style="margin-bottom: 1rem; color: var(--text-secondary); font-size: 0.9rem;"> | |
| Recent Formulas | |
| </h4> | |
| <div id="historyList"> | |
| <!-- History items will be populated by JS --> | |
| </div> | |
| <button class="btn btn-secondary btn-sm" style="width: 100%; margin-top: 1rem;" onclick="clearHistory()"> | |
| <i class="fas fa-trash-alt"></i> | |
| Clear History | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Toast Container --> | |
| <div class="toast-container" id="toastContainer"></div> | |
| <script> | |
| // Application State | |
| const state = { | |
| history: [], | |
| evalCount: 0, | |
| successCount: 0, | |
| presets: [ | |
| { | |
| name: "Quadratic Formula", | |
| formula: "\\frac{-b + \\sqrt{b^2 - 4ac}}{2a}", | |
| icon: "fa-square-root-alt" | |
| }, | |
| { | |
| name: "FPS Calculation", | |
| formula: "FPS = \\frac{1000}{FrameTime}", | |
| icon: "fa-tachometer-alt" | |
| }, | |
| { | |
| name: "Frame Budget", | |
| formula: "\\frac{1000}{RefreshRate}", | |
| icon: "fa-clock" | |
| }, | |
| { | |
| name: "Motion Blur Amount", | |
| formula: "\\frac{AngularVelocity \\times FOV}{FPS}", | |
| icon: "fa-eye" | |
| }, | |
| { | |
| name: "Latency Chain", | |
| formula: "TotalLatency = Input + Sim + Render + Present", | |
| icon: "fa-link" | |
| }, | |
| { | |
| name: "Asynchronous Compute", | |
| formula: "\\frac{GPU \\times Cores}{Compute \\div Shader}", | |
| icon: "fa-microchip" | |
| }, | |
| { | |
| name: "Ray Tracing BVH", | |
| formula: "\\frac{Traversal \\times Depth}{Intersections}", | |
| icon: "fa-cube" | |
| }, | |
| { | |
| name: "Frame Time Variance", | |
| formula: "\\sqrt{\\frac{\\sum(x - \\bar{x})^2}{n}}", | |
| icon: "fa-chart-area" | |
| } | |
| ] | |
| }; | |
| // Initialize Application | |
| document.addEventListener('DOMContentLoaded', () => { | |
| initializePresets(); | |
| initializeTabs(); | |
| renderFormula(); | |
| calculateFPS(); | |
| advancedFPSCalc(); | |
| loadHistory(); | |
| updateStats(); | |
| }); | |
| // Initialize Presets | |
| function initializePresets() { | |
| const presetList = document.getElementById('presetList'); | |
| state.presets.forEach((preset, index) => { | |
| const li = document.createElement('li'); | |
| li.className = 'preset-item'; | |
| li.innerHTML = ` | |
| <div class="preset-name"> | |
| <i class="fas ${preset.icon}"></i> | |
| ${preset.name} | |
| </div> | |
| <div class="preset-formula">${preset.formula}</div> | |
| `; | |
| li.onclick = () => loadPreset(preset); | |
| presetList.appendChild(li); | |
| }); | |
| } | |
| // Initialize Tabs | |
| function initializeTabs() { | |
| const tabs = document.querySelectorAll('.tab'); | |
| tabs.forEach(tab => { | |
| tab.addEventListener('click', () => { | |
| tabs.forEach(t => t.classList.remove('active')); | |
| tab.classList.add('active'); | |
| const tabName = tab.dataset.tab; | |
| document.getElementById('editorTab').style.display = tabName === 'editor' ? 'block' : 'none'; | |
| document.getElementById('fpsTab').style.display = tabName === 'fps' ? 'block' : 'none'; | |
| }); | |
| }); | |
| } | |
| // Render Formula using KaTeX | |
| function renderFormula() { | |
| const formula = document.getElementById('formulaInput').value; | |
| const container = document.getElementById('renderedFormula'); | |
| try { | |
| katex.render(formula, container, { | |
| throwOnError: false, | |
| displayMode: true, | |
| output: 'html', | |
| trust: true, | |
| strict: false | |
| }); | |
| // Add to history | |
| addToHistory(formula); | |
| // Detect variables | |
| detectVariables(formula); | |
| // Update stats | |
| state.evalCount++; | |
| state.successCount++; | |
| updateStats(); | |
| showToast('Formula rendered successfully!', 'success'); | |
| } catch (error) { | |
| showToast('Error rendering formula: ' + error.message, 'error'); | |
| } | |
| } | |
| // Detect Variables from Formula | |
| function detectVariables(formula) { | |
| // Simple regex to find single letter variables | |
| const matches = formula.match(/[a-zA-Z](?![a-zA-Z])/g); | |
| const uniqueVars = [...new Set(matches)]; | |
| if (uniqueVars.length > 0) { | |
| const variablesList = document.getElementById('variablesList'); | |
| let html = ''; | |
| // Group variables | |
| const groups = []; | |
| for (let i = 0; i < uniqueVars.length; i += 3) { | |
| groups.push(uniqueVars.slice(i, i + 3)); | |
| } | |
| groups.forEach((group, idx) => { | |
| html += ` | |
| <div class="variable-item"> | |
| <div class="variable-header"> | |
| <span class="variable-name">${group.join(', ')}</span> | |
| <span class="variable-type">Auto-detected</span> | |
| </div> | |
| <div class="variable-value"> | |
| ${group.map(v => ` | |
| <input type="text" class="variable-input" | |
| placeholder="${v}=" | |
| id="var_${v}" | |
| style="flex: 1;" | |
| onkeypress="if(event.key==='Enter')evaluateFormula()"> | |
| `).join('')} | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| variablesList.innerHTML = html; | |
| document.getElementById('variableCount').textContent = uniqueVars.length; | |
| } | |
| } | |
| // Evaluate Formula (Basic Implementation) | |
| function evaluateFormula() { | |
| const formula = document.getElementById('formulaInput').value; | |
| const inputs = document.querySelectorAll('.variable-input'); | |
| const values = {}; | |
| inputs.forEach(input => { | |
| if (input.id.startsWith('var_') && input.value) { | |
| const variable = input.id.split('_')[1]; | |
| values[variable] = parseFloat(input.value); | |
| } | |
| }); | |
| if (Object.keys(values).length === 0) { | |
| showToast('Please enter variable values first', 'info'); | |
| return; | |
| } | |
| try { | |
| // Very basic evaluation - for production, use math.js | |
| let result = formula; | |
| // Replace variables with values | |
| Object.entries(values).forEach(([key, val]) => { | |
| result = result.replace(new RegExp(`\\b${key}\\b`, 'g'), val); | |
| }); | |
| // Evaluate the expression | |
| // Note: This is a simplified evaluation - use math.js for complex cases | |
| result = Function('"use strict";return (' + result + ')')(); | |
| if (isFinite(result) && !isNaN(result)) { | |
| document.getElementById('evaluationResult').style.display = 'block'; | |
| document.getElementBy |