|
| 1 | +import { wrapText } from '../utils'; |
| 2 | + |
| 3 | +export const cadTech = (ctx, width, height, scale, data) => { |
| 4 | + const { |
| 5 | + primaryColor, |
| 6 | + secondaryColor, |
| 7 | + bgColor, |
| 8 | + repoOwner, |
| 9 | + repoName, |
| 10 | + description, |
| 11 | + language, |
| 12 | + stars, |
| 13 | + } = data; |
| 14 | + |
| 15 | + const padding = 60 * scale; |
| 16 | + const borderWidth = 4; // Fixed value |
| 17 | + |
| 18 | + // 1. Engineering Background (Blueprint/CAD Style) |
| 19 | + ctx.fillStyle = bgColor; |
| 20 | + ctx.fillRect(0, 0, width, height); |
| 21 | + |
| 22 | + // 2. Technical Grid (CAD Style) |
| 23 | + ctx.strokeStyle = '#ffffff'; |
| 24 | + ctx.globalAlpha = 0.05; |
| 25 | + ctx.lineWidth = 1 * scale; |
| 26 | + const gridSize = 40 * scale; |
| 27 | + for (let x = 0; x < width; x += gridSize) { |
| 28 | + ctx.beginPath(); |
| 29 | + ctx.moveTo(x, 0); |
| 30 | + ctx.lineTo(x, height); |
| 31 | + ctx.stroke(); |
| 32 | + } |
| 33 | + for (let y = 0; y < height; y += gridSize) { |
| 34 | + ctx.beginPath(); |
| 35 | + ctx.moveTo(0, y); |
| 36 | + ctx.lineTo(width, y); |
| 37 | + ctx.stroke(); |
| 38 | + } |
| 39 | + ctx.globalAlpha = 1.0; |
| 40 | + |
| 41 | + // 3. Technical Border (using borderWidth and secondaryColor) |
| 42 | + ctx.strokeStyle = secondaryColor; |
| 43 | + ctx.lineWidth = borderWidth * scale; |
| 44 | + ctx.strokeRect(padding, padding, width - padding * 2, height - padding * 2); |
| 45 | + |
| 46 | + // Corner Accents (Measurement lines) |
| 47 | + ctx.lineWidth = 2 * scale; |
| 48 | + ctx.strokeStyle = primaryColor; |
| 49 | + const cornerSize = 40 * scale; |
| 50 | + |
| 51 | + // Top Left Accents |
| 52 | + ctx.beginPath(); |
| 53 | + ctx.moveTo(padding - 20 * scale, padding); |
| 54 | + ctx.lineTo(padding + cornerSize, padding); |
| 55 | + ctx.stroke(); |
| 56 | + ctx.beginPath(); |
| 57 | + ctx.moveTo(padding, padding - 20 * scale); |
| 58 | + ctx.lineTo(padding, padding + cornerSize); |
| 59 | + ctx.stroke(); |
| 60 | + |
| 61 | + // 4. Content - Architectural Layout |
| 62 | + ctx.textAlign = 'left'; |
| 63 | + |
| 64 | + // Project Info Box (Top Right) |
| 65 | + const infoW = 300 * scale; |
| 66 | + const infoH = 100 * scale; |
| 67 | + const infoX = width - padding - infoW - 20 * scale; |
| 68 | + const infoY = padding + 20 * scale; |
| 69 | + |
| 70 | + ctx.strokeStyle = secondaryColor; |
| 71 | + ctx.strokeRect(infoX, infoY, infoW, infoH); |
| 72 | + |
| 73 | + ctx.font = `bold ${16 * scale}px "JetBrains Mono", monospace`; |
| 74 | + ctx.fillStyle = secondaryColor; |
| 75 | + ctx.fillText('REF_NODE: 0x2026', infoX + 15 * scale, infoY + 30 * scale); |
| 76 | + ctx.fillText(`OWNER: ${repoOwner.toUpperCase()}`, infoX + 15 * scale, infoY + 60 * scale); |
| 77 | + ctx.fillText(`DATE: ${new Date().toLocaleDateString()}`, infoX + 15 * scale, infoY + 85 * scale); |
| 78 | + |
| 79 | + // Main Heading (Blueprint style) |
| 80 | + ctx.font = `900 ${110 * scale}px "Inter", sans-serif`; |
| 81 | + ctx.fillStyle = '#ffffff'; |
| 82 | + ctx.fillText(repoName, padding + 40 * scale, padding + 160 * scale); |
| 83 | + |
| 84 | + // Underline with Measurement labels |
| 85 | + ctx.lineWidth = 2 * scale; |
| 86 | + ctx.strokeStyle = primaryColor; |
| 87 | + ctx.beginPath(); |
| 88 | + ctx.moveTo(padding + 40 * scale, padding + 180 * scale); |
| 89 | + ctx.lineTo(width - padding - 40 * scale, padding + 180 * scale); |
| 90 | + ctx.stroke(); |
| 91 | + |
| 92 | + ctx.font = `bold ${12 * scale}px "JetBrains Mono", monospace`; |
| 93 | + ctx.fillStyle = primaryColor; |
| 94 | + ctx.fillText(`${width - padding * 2}mm_REF`, width / 2, padding + 175 * scale); |
| 95 | + |
| 96 | + // Description (Architectural notes) |
| 97 | + ctx.font = `${30 * scale}px "Inter", sans-serif`; |
| 98 | + ctx.fillStyle = 'rgba(255, 255, 255, 0.7)'; |
| 99 | + wrapText( |
| 100 | + ctx, |
| 101 | + description.toUpperCase(), |
| 102 | + padding + 40 * scale, |
| 103 | + padding + 250 * scale, |
| 104 | + width - padding * 3, |
| 105 | + 45 * scale |
| 106 | + ); |
| 107 | + |
| 108 | + // 5. Tech Metadata (Bottom) |
| 109 | + const footerY = height - padding - 40 * scale; |
| 110 | + |
| 111 | + // Language Chip |
| 112 | + ctx.fillStyle = secondaryColor; |
| 113 | + ctx.fillRect(padding + 40 * scale, footerY, 180 * scale, 60 * scale); |
| 114 | + ctx.fillStyle = '#000000'; |
| 115 | + ctx.font = `bold ${24 * scale}px "JetBrains Mono", monospace`; |
| 116 | + ctx.textAlign = 'center'; |
| 117 | + ctx.fillText(language.toUpperCase(), padding + 40 * scale + 90 * scale, footerY + 38 * scale); |
| 118 | + // Metrics (Table style) |
| 119 | + ctx.textAlign = 'right'; |
| 120 | + ctx.font = `bold ${20 * scale}px "JetBrains Mono", monospace`; |
| 121 | + ctx.fillStyle = '#ffffff'; |
| 122 | + ctx.fillText(`| ST_REF: ${stars} | FK_REF: ${stars / 2} |`, width - padding - 40 * scale, footerY + 35 * scale); |
| 123 | +}; |
0 commit comments