add apu bingo

This commit is contained in:
2026-05-25 09:20:40 +02:00
parent 92cc474ca3
commit d4a68f59fd

View File

@@ -367,14 +367,16 @@
} }
const category = (window.memeTemplate && window.memeTemplate.category) ? window.memeTemplate.category.toLowerCase() : ''; const category = (window.memeTemplate && window.memeTemplate.category) ? window.memeTemplate.category.toLowerCase() : '';
const subCategory = (window.memeTemplate && window.memeTemplate.sub_category) ? window.memeTemplate.sub_category.toLowerCase() : ''; const subCategory = (window.memeTemplate && window.memeTemplate.sub_category) ? window.memeTemplate.sub_category.toLowerCase() : '';
const templateId = (window.memeTemplate && window.memeTemplate.id) ? window.memeTemplate.id.toLowerCase() : '';
const isOrakelVon10 = subCategory === 'von10'; const isOrakelVon10 = subCategory === 'von10';
const isOrakelUser = subCategory === 'user'; const isOrakelUser = subCategory === 'user';
const isOrakelNormal = category === 'orakel' && !isOrakelUser && !isOrakelVon10; const isOrakelBingoApu = subCategory === 'bingoapu' || templateId === 'bingoapu';
const isOrakelNormal = category === 'orakel' && !isOrakelUser && !isOrakelVon10 && !isOrakelBingoApu;
let uploadCanvas = canvas; let uploadCanvas = canvas;
if (isOrakelNormal || isOrakelUser || isOrakelVon10) { if (isOrakelNormal || isOrakelUser || isOrakelVon10 || isOrakelBingoApu) {
// Create an off-screen canvas to apply the orakel answer silently // Create an off-screen canvas to apply the orakel answer silently
uploadCanvas = document.createElement('canvas'); uploadCanvas = document.createElement('canvas');
uploadCanvas.width = canvas.width; uploadCanvas.width = canvas.width;
@@ -385,6 +387,7 @@
uCtx.drawImage(canvas, 0, 0); uCtx.drawImage(canvas, 0, 0);
let result = ''; let result = '';
let selectedCorner = null;
if (isOrakelNormal) { if (isOrakelNormal) {
const outcomes = ['JA', 'NEIN', 'VIELLEICHT', 'AUF JEDEN FALL', 'NIEMALS', 'SOWAS VON JA', 'VERGISS ES', 'FRAG SPÄTER', 'KOMMT DRAUF AN']; const outcomes = ['JA', 'NEIN', 'VIELLEICHT', 'AUF JEDEN FALL', 'NIEMALS', 'SOWAS VON JA', 'VERGISS ES', 'FRAG SPÄTER', 'KOMMT DRAUF AN'];
result = outcomes[Math.floor(Math.random() * outcomes.length)]; result = outcomes[Math.floor(Math.random() * outcomes.length)];
@@ -398,92 +401,115 @@
} }
} else if (isOrakelVon10) { } else if (isOrakelVon10) {
result = Math.floor(Math.random() * 11).toString(); result = Math.floor(Math.random() * 11).toString();
} else if (isOrakelBingoApu) {
const corners = [
{ x: 60, y: 100, label: 'YES' },
{ x: 573, y: 100, label: 'NO' },
{ x: 60, y: 615, label: 'NO' },
{ x: 573, y: 615, label: 'YES' }
];
selectedCorner = corners[Math.floor(Math.random() * corners.length)];
result = selectedCorner.label;
} }
// Draw Orakel result on the hidden canvas // Draw Orakel result on the hidden canvas
uCtx.save(); uCtx.save();
uCtx.font = (isOrakelVon10) ? 'bold 150px Impact' : 'bold 80px Impact'; // Bigger font for the rating if (isOrakelBingoApu) {
uCtx.textAlign = 'center'; // Draw "KOPS" in normal meme text style on the selected corner
uCtx.textBaseline = 'middle'; uCtx.font = `bold 28px ${memeFont}`;
uCtx.textAlign = 'center';
uCtx.textBaseline = 'middle';
uCtx.fillStyle = '#fff';
uCtx.strokeStyle = '#000';
uCtx.lineWidth = 4;
uCtx.miterLimit = 2;
if (isOrakelNormal) { uCtx.strokeText('KOPS', selectedCorner.x, selectedCorner.y);
uCtx.shadowBlur = 20; uCtx.fillText('KOPS', selectedCorner.x, selectedCorner.y);
uCtx.shadowColor = 'rgba(101, 37, 212, 1)';
} else if (isOrakelVon10) {
uCtx.shadowBlur = 0; // No shadow as requested
} else { } else {
// No shadow for the User Orakel uCtx.font = (isOrakelVon10) ? 'bold 150px Impact' : 'bold 80px Impact'; // Bigger font for the rating
uCtx.shadowBlur = 0; uCtx.textAlign = 'center';
} uCtx.textBaseline = 'middle';
uCtx.fillStyle = '#fff'; if (isOrakelNormal) {
uCtx.strokeStyle = '#000'; uCtx.shadowBlur = 20;
uCtx.lineWidth = 10; uCtx.shadowColor = 'rgba(101, 37, 212, 1)';
uCtx.miterLimit = 2; } else if (isOrakelVon10) {
uCtx.shadowBlur = 0; // No shadow as requested
// Adjust position for user Orakel (reverting to +10 offset)
let yPos = Math.round(isOrakelUser ? (uploadCanvas.height / 2 + 10) : (uploadCanvas.height / 2 + 50));
if (isOrakelVon10) {
yPos = Math.round(uploadCanvas.height / 2 ); // 1px lower
}
const xPos = Math.round(uploadCanvas.width / 2);
// Auto-fit font size for user orakel — shrink until text fits within image width
let orakelFontSize = isOrakelVon10 ? 150 : 80;
const maxTextWidth = uploadCanvas.width - 80; // 40px padding each side
if (isOrakelUser) {
const parts = result.split('|||');
const namePart = parts[0];
const idPart = parts.length > 1 ? `(${parts[1]})` : '';
const combinedText = idPart ? `${namePart} ${idPart}` : namePart;
// Even tighter threshold for User Orakel (approx 25% total padding)
const userMaxWidth = Math.round(uploadCanvas.width * 0.75);
let currentFontSize = 74;
uCtx.font = `bold ${currentFontSize}px Impact`;
// First attempt: Shrink entire text on one line down to 58px if needed
while (uCtx.measureText(combinedText).width > userMaxWidth && currentFontSize > 58) {
currentFontSize -= 2;
uCtx.font = `bold ${currentFontSize}px Impact`;
}
const combinedFits = uCtx.measureText(combinedText).width <= userMaxWidth;
if (combinedFits) {
// Single line — potentially shrunk for long names
uCtx.fillText(combinedText, xPos, yPos);
} else { } else {
// Two lines — auto-fit just the name, ID below // No shadow for the User Orakel
let nameFontSize = 74; uCtx.shadowBlur = 0;
uCtx.font = `bold ${nameFontSize}px Impact`; }
while (uCtx.measureText(namePart).width > userMaxWidth && nameFontSize > 16) {
nameFontSize -= 2; uCtx.fillStyle = '#fff';
uCtx.font = `bold ${nameFontSize}px Impact`; uCtx.strokeStyle = '#000';
} uCtx.lineWidth = 10;
uCtx.miterLimit = 2;
const idFontSize = Math.max(18, Math.round(nameFontSize * 0.45));
const lineGap = Math.round(nameFontSize * 0.65); // Adjust position for user Orakel (reverting to +10 offset)
const nameY = Math.round(yPos - lineGap / 2); let yPos = Math.round(isOrakelUser ? (uploadCanvas.height / 2 + 10) : (uploadCanvas.height / 2 + 50));
const idY = Math.round(yPos + lineGap / 2) + 2;
if (isOrakelVon10) {
uCtx.font = `bold ${nameFontSize}px Impact`; yPos = Math.round(uploadCanvas.height / 2 ); // 1px lower
uCtx.fillText(namePart, xPos, nameY); }
if (idPart) { const xPos = Math.round(uploadCanvas.width / 2);
uCtx.font = `bold ${idFontSize}px Impact`;
uCtx.fillText(idPart, xPos, idY); // Auto-fit font size for user orakel — shrink until text fits within image width
} let orakelFontSize = isOrakelVon10 ? 150 : 80;
const maxTextWidth = uploadCanvas.width - 80; // 40px padding each side
if (isOrakelUser) {
const parts = result.split('|||');
const namePart = parts[0];
const idPart = parts.length > 1 ? `(${parts[1]})` : '';
const combinedText = idPart ? `${namePart} ${idPart}` : namePart;
// Even tighter threshold for User Orakel (approx 25% total padding)
const userMaxWidth = Math.round(uploadCanvas.width * 0.75);
let currentFontSize = 74;
uCtx.font = `bold ${currentFontSize}px Impact`;
// First attempt: Shrink entire text on one line down to 58px if needed
while (uCtx.measureText(combinedText).width > userMaxWidth && currentFontSize > 58) {
currentFontSize -= 2;
uCtx.font = `bold ${currentFontSize}px Impact`;
}
const combinedFits = uCtx.measureText(combinedText).width <= userMaxWidth;
if (combinedFits) {
// Single line — potentially shrunk for long names
uCtx.fillText(combinedText, xPos, yPos);
} else {
// Two lines — auto-fit just the name, ID below
let nameFontSize = 74;
uCtx.font = `bold ${nameFontSize}px Impact`;
while (uCtx.measureText(namePart).width > userMaxWidth && nameFontSize > 16) {
nameFontSize -= 2;
uCtx.font = `bold ${nameFontSize}px Impact`;
}
const idFontSize = Math.max(18, Math.round(nameFontSize * 0.45));
const lineGap = Math.round(nameFontSize * 0.65);
const nameY = Math.round(yPos - lineGap / 2);
const idY = Math.round(yPos + lineGap / 2) + 2;
uCtx.font = `bold ${nameFontSize}px Impact`;
uCtx.fillText(namePart, xPos, nameY);
if (idPart) {
uCtx.font = `bold ${idFontSize}px Impact`;
uCtx.fillText(idPart, xPos, idY);
}
}
} else {
// Normal / von10 — single line as before
uCtx.font = `bold ${orakelFontSize}px Impact`;
uCtx.strokeText(result, xPos, yPos);
uCtx.fillText(result, xPos, yPos);
} }
} else {
// Normal / von10 — single line as before
uCtx.font = `bold ${orakelFontSize}px Impact`;
uCtx.strokeText(result, xPos, yPos);
uCtx.fillText(result, xPos, yPos);
} }
uCtx.restore(); uCtx.restore();
} }