You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, topText = "ЧЕМПИОНАТ ПО ЛЕНИ", bottomText = "АБСОЛЮТНЫЙ ЧЕМПИОН", addMedal = 1, showZzz = 1) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = originalImg.width;
canvas.height = originalImg.height;
// Draw the original image onto the canvas
ctx.drawImage(originalImg, 0, 0);
// Filter: Draw floating "Zzz" marks if enabled
if (showZzz === 1) {
const zPositions = [
{ x: 0.15, y: 0.20, s: 0.09 },
{ x: 0.85, y: 0.30, s: 0.12 },
{ x: 0.20, y: 0.75, s: 0.07 },
{ x: 0.80, y: 0.70, s: 0.10 },
{ x: 0.50, y: 0.45, s: 0.05 }
];
ctx.fillStyle = "rgba(255, 255, 255, 0.75)";
ctx.strokeStyle = "rgba(0, 0, 0, 0.6)";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
for (let z of zPositions) {
const s = Math.min(canvas.width, canvas.height) * z.s;
ctx.font = `bold ${s}px 'Comic Sans MS', cursive, sans-serif`;
ctx.lineWidth = Math.max(2, s * 0.1);
// Draw rotated Z's for a sleepy effect
ctx.save();
ctx.translate(canvas.width * z.x, canvas.height * z.y);
ctx.rotate((Math.random() * 0.4) - 0.2); // slight random rotation
ctx.strokeText("Z", 0, 0);
ctx.fillText("Z", 0, 0);
ctx.restore();
}
}
// Function to draw classic meme text
const drawMemeText = (text, yPos, isTop) => {
if (!text) return;
let fontSize = Math.floor(canvas.height / 8);
ctx.font = `bold ${fontSize}px Impact, 'Arial Black', sans-serif`;
ctx.textAlign = "center";
ctx.textBaseline = isTop ? "top" : "bottom";
// Measure and scale down text if it's too wide for the canvas
let textWidth = ctx.measureText(text).width;
let maxWidth = canvas.width * 0.95;
if (textWidth > maxWidth) {
fontSize = Math.floor(fontSize * (maxWidth / textWidth));
ctx.font = `bold ${fontSize}px Impact, 'Arial Black', sans-serif`;
}
ctx.lineWidth = Math.max(3, fontSize / 12);
ctx.strokeStyle = "#000000";
ctx.fillStyle = "#FFFFFF";
const x = canvas.width / 2;
ctx.strokeText(text, x, yPos);
ctx.fillText(text, x, yPos);
};
// Draw Top & Bottom Texts
drawMemeText(topText, canvas.height * 0.03, true);
drawMemeText(bottomText, canvas.height * 0.97, false);
// Draw a "1st Place Lazy" Medal in the corner
if (addMedal === 1) {
const r = Math.min(canvas.width, canvas.height) * 0.12;
const medalX = canvas.width - r - Math.max(20, canvas.width * 0.03);
const medalY = canvas.height - r * 2.5;
ctx.shadowColor = "rgba(0,0,0,0.5)";
ctx.shadowBlur = 8;
ctx.shadowOffsetX = 4;
ctx.shadowOffsetY = 4;
// Draw Ribbons
ctx.fillStyle = "#D32F2F"; // Classic Red
ctx.strokeStyle = "#8B0000";
ctx.lineWidth = r * 0.05;
// Left Ribbon Tail
ctx.beginPath();
ctx.moveTo(medalX - r * 0.4, medalY);
ctx.lineTo(medalX - r * 0.9, medalY + r * 1.8);
ctx.lineTo(medalX - r * 0.5, medalY + r * 1.5);
ctx.lineTo(medalX - r * 0.1, medalY + r * 1.8);
ctx.closePath();
ctx.fill();
ctx.stroke();
// Right Ribbon Tail
ctx.beginPath();
ctx.moveTo(medalX + r * 0.4, medalY);
ctx.lineTo(medalX + r * 0.9, medalY + r * 1.8);
ctx.lineTo(medalX + r * 0.5, medalY + r * 1.5);
ctx.lineTo(medalX + r * 0.1, medalY + r * 1.8);
ctx.closePath();
ctx.fill();
ctx.stroke();
// Remove shadow for the clean interior vector lines
ctx.shadowColor = "transparent";
// Outer Gold Coin
ctx.beginPath();
ctx.arc(medalX, medalY, r, 0, Math.PI * 2);
ctx.fillStyle = "#FFDF00"; // Rich Gold
ctx.fill();
ctx.lineWidth = r * 0.1;
ctx.strokeStyle = "#DAA520";
ctx.stroke();
// Inner Engraving Circle
ctx.beginPath();
ctx.arc(medalX, medalY, r * 0.75, 0, Math.PI * 2);
ctx.lineWidth = r * 0.03;
ctx.strokeStyle = "#B8860B";
ctx.stroke();
// Medal Texts ("Zzz" & "I МЕСТО")
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.font = `bold ${r * 0.5}px Impact, sans-serif`;
ctx.fillStyle = "#8B6508";
ctx.fillText("Zzz", medalX, medalY - r * 0.15);
ctx.font = `bold ${r * 0.25}px 'Arial Black', sans-serif`;
ctx.fillStyle = "#8B6508";
ctx.fillText("I МЕСТО", medalX, medalY + r * 0.35);
}
return canvas;
}
Apply Changes