|
| 1 | +import { wrapText } from '../utils'; |
| 2 | + |
| 3 | +export const quantumOverlay = (ctx, width, height, scale, data) => { |
| 4 | + const { |
| 5 | + primaryColor, |
| 6 | + secondaryColor, |
| 7 | + bgColor, |
| 8 | + repoOwner, |
| 9 | + repoName, |
| 10 | + description, |
| 11 | + language, |
| 12 | + stars, |
| 13 | + forks, |
| 14 | + } = data; |
| 15 | + |
| 16 | + const padding = 60 * scale; |
| 17 | + |
| 18 | + // 1. Deep Space Background (using bgColor) |
| 19 | + ctx.fillStyle = bgColor; |
| 20 | + ctx.fillRect(0, 0, width, height); |
| 21 | + |
| 22 | + // 2. Quantum Particle Field (Background) |
| 23 | + ctx.save(); |
| 24 | + for (let i = 0; i < 40; i++) { |
| 25 | + const x = Math.random() * width; |
| 26 | + const y = Math.random() * height; |
| 27 | + const radius = Math.random() * 3 * scale; |
| 28 | + |
| 29 | + ctx.beginPath(); |
| 30 | + ctx.arc(x, y, radius, 0, Math.PI * 2); |
| 31 | + ctx.fillStyle = i % 2 === 0 ? primaryColor : secondaryColor; |
| 32 | + ctx.globalAlpha = 0.2; |
| 33 | + ctx.fill(); |
| 34 | + |
| 35 | + // Random Connection Lines |
| 36 | + if (i < 15) { |
| 37 | + ctx.beginPath(); |
| 38 | + ctx.moveTo(x, y); |
| 39 | + ctx.lineTo(x + (Math.random() - 0.5) * 200 * scale, y + (Math.random() - 0.5) * 200 * scale); |
| 40 | + ctx.strokeStyle = primaryColor; |
| 41 | + ctx.globalAlpha = 0.1; |
| 42 | + ctx.stroke(); |
| 43 | + } |
| 44 | + } |
| 45 | + ctx.restore(); |
| 46 | + |
| 47 | + // 3. Central HUD Ring (Gradient Stroke) |
| 48 | + ctx.save(); |
| 49 | + const centerX = width / 2; |
| 50 | + const centerY = height / 2; |
| 51 | + const radius = 280 * scale; |
| 52 | + |
| 53 | + ctx.beginPath(); |
| 54 | + ctx.arc(centerX, centerY, radius, 0, Math.PI * 2); |
| 55 | + const hudGradient = ctx.createLinearGradient(centerX - radius, centerY, centerX + radius, centerY); |
| 56 | + hudGradient.addColorStop(0, primaryColor); |
| 57 | + hudGradient.addColorStop(1, secondaryColor); |
| 58 | + ctx.strokeStyle = hudGradient; |
| 59 | + ctx.lineWidth = 1 * scale; |
| 60 | + ctx.globalAlpha = 0.3; |
| 61 | + ctx.stroke(); |
| 62 | + |
| 63 | + // HUD Accents (Arcs) |
| 64 | + ctx.lineWidth = 4 * scale; |
| 65 | + ctx.globalAlpha = 0.8; |
| 66 | + ctx.beginPath(); |
| 67 | + ctx.arc(centerX, centerY, radius, -Math.PI / 4, Math.PI / 4); |
| 68 | + ctx.stroke(); |
| 69 | + ctx.beginPath(); |
| 70 | + ctx.arc(centerX, centerY, radius, Math.PI * 0.75, Math.PI * 1.25); |
| 71 | + ctx.stroke(); |
| 72 | + ctx.restore(); |
| 73 | + |
| 74 | + // 4. Content - Floating in Center |
| 75 | + ctx.textAlign = 'center'; |
| 76 | + ctx.textBaseline = 'middle'; |
| 77 | + |
| 78 | + // Repo Owner (Technical Label) |
| 79 | + ctx.font = `bold ${24 * scale}px "JetBrains Mono", monospace`; |
| 80 | + ctx.fillStyle = secondaryColor; |
| 81 | + ctx.fillText(`// NODE: ${repoOwner.toUpperCase()}`, centerX, centerY - 160 * scale); |
| 82 | + |
| 83 | + // Repo Name (Bold, Glowing) |
| 84 | + ctx.save(); |
| 85 | + ctx.font = `900 ${120 * scale}px "Inter", "Arial Black", sans-serif`; |
| 86 | + ctx.shadowColor = primaryColor; |
| 87 | + ctx.shadowBlur = 30 * scale; |
| 88 | + ctx.fillStyle = '#ffffff'; |
| 89 | + ctx.fillText(repoName, centerX, centerY - 40 * scale); |
| 90 | + ctx.restore(); |
| 91 | + |
| 92 | + // Description (Wrapped in middle) |
| 93 | + ctx.font = `300 ${32 * scale}px "Inter", sans-serif`; |
| 94 | + ctx.fillStyle = 'rgba(255, 255, 255, 0.8)'; |
| 95 | + wrapText( |
| 96 | + ctx, |
| 97 | + description, |
| 98 | + centerX, |
| 99 | + centerY + 60 * scale, |
| 100 | + width * 0.6, |
| 101 | + 45 * scale |
| 102 | + ); |
| 103 | + |
| 104 | + // 5. Data Points (Floating around) |
| 105 | + const drawDataPoint = (x, y, label, value, color) => { |
| 106 | + ctx.textAlign = 'center'; |
| 107 | + ctx.font = `bold ${16 * scale}px "JetBrains Mono", monospace`; |
| 108 | + ctx.fillStyle = color; |
| 109 | + ctx.fillText(label, x, y - 25 * scale); |
| 110 | + |
| 111 | + ctx.font = `900 ${36 * scale}px "Inter", sans-serif`; |
| 112 | + ctx.fillStyle = '#ffffff'; |
| 113 | + ctx.fillText(value, x, y + 10 * scale); |
| 114 | + |
| 115 | + // Decorative bracket |
| 116 | + ctx.strokeStyle = color; |
| 117 | + ctx.lineWidth = 2 * scale; |
| 118 | + ctx.beginPath(); |
| 119 | + ctx.moveTo(x - 40 * scale, y - 40 * scale); |
| 120 | + ctx.lineTo(x - 50 * scale, y - 40 * scale); |
| 121 | + ctx.lineTo(x - 50 * scale, y + 20 * scale); |
| 122 | + ctx.lineTo(x - 40 * scale, y + 20 * scale); |
| 123 | + ctx.stroke(); |
| 124 | + }; |
| 125 | + |
| 126 | + const dataY = height - padding - 60 * scale; |
| 127 | + drawDataPoint(width * 0.25, dataY, 'STARS_QUANTUM', stars, primaryColor); |
| 128 | + drawDataPoint(width * 0.75, dataY, 'FORKS_DISTRIB', forks, secondaryColor); |
| 129 | + |
| 130 | + // Language (Bottom Center) |
| 131 | + ctx.font = `bold ${20 * scale}px "JetBrains Mono", monospace`; |
| 132 | + ctx.fillStyle = 'rgba(255, 255, 255, 0.4)'; |
| 133 | + ctx.fillText(`RUNTIME::${language.toUpperCase()}`, centerX, height - padding); |
| 134 | + |
| 135 | + // Scanline/Grid Overlay |
| 136 | + ctx.save(); |
| 137 | + ctx.globalAlpha = 0.03; |
| 138 | + ctx.fillStyle = '#ffffff'; |
| 139 | + for (let i = 0; i < height; i += 4 * scale) { |
| 140 | + ctx.fillRect(0, i, width, 1 * scale); |
| 141 | + } |
| 142 | + ctx.restore(); |
| 143 | +}; |
0 commit comments