You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, tvColor = "#ff9f43", accentColor = "#2f3542", bgColor = "transparent") {
// Create canvas of a standard hi-res icon size
const canvas = document.createElement("canvas");
const size = 1024;
canvas.width = size;
canvas.height = size;
const ctx = canvas.getContext("2d");
// Helper function to draw rounded rectangles
function drawRoundRect(x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
}
// Draw Background
if (bgColor !== "transparent") {
ctx.fillStyle = bgColor;
ctx.fillRect(0, 0, size, size);
}
// 1. Draw TV Legs
ctx.lineCap = "round";
ctx.lineWidth = 24;
ctx.strokeStyle = accentColor;
ctx.beginPath();
ctx.moveTo(250, 750);
ctx.lineTo(150, 920);
ctx.stroke(); // Left leg
ctx.beginPath();
ctx.moveTo(774, 750);
ctx.lineTo(874, 920);
ctx.stroke(); // Right leg
// 2. Draw Antenna Rods
ctx.lineWidth = 12;
ctx.beginPath();
ctx.moveTo(512, 232);
ctx.lineTo(320, 80);
ctx.stroke(); // Left Antenna
ctx.beginPath();
ctx.moveTo(512, 232);
ctx.lineTo(704, 80);
ctx.stroke(); // Right Antenna
// Antenna Tips
ctx.fillStyle = accentColor;
ctx.beginPath();
ctx.arc(320, 80, 20, 0, Math.PI * 2);
ctx.fill();
ctx.beginPath();
ctx.arc(704, 80, 20, 0, Math.PI * 2);
ctx.fill();
// 3. Draw Antenna Base
ctx.fillStyle = tvColor;
drawRoundRect(512 - 50, 200, 100, 60, 20);
ctx.fill();
// 4. Draw Main TV Body
ctx.shadowColor = "rgba(0, 0, 0, 0.3)";
ctx.shadowBlur = 30;
ctx.shadowOffsetY = 15;
drawRoundRect(92, 232, 840, 560, 40);
ctx.fill();
ctx.shadowColor = "transparent"; // Reset shadow
// 5. Draw Glossy Highlight on TV Body
ctx.save();
drawRoundRect(92, 232, 840, 560, 40);
ctx.clip();
ctx.fillStyle = "rgba(255, 255, 255, 0.15)";
ctx.beginPath();
ctx.moveTo(0, 0);
ctx.lineTo(1024, 0);
ctx.lineTo(1024, 400);
ctx.lineTo(0, 600);
ctx.closePath();
ctx.fill();
ctx.restore();
// 6. Draw Screen Bezel (Outer dark frame)
ctx.fillStyle = accentColor;
drawRoundRect(132, 272, 630, 480, 30);
ctx.fill();
// 7. Draw Inner Screen area (with input image inserted)
drawRoundRect(147, 287, 600, 450, 20);
ctx.save();
ctx.clip(); // Mask following drawings to screen bounds
// Scale original image to cover the screen (object-fit: cover equivalent)
if (originalImg && originalImg.width && originalImg.height) {
const scale = Math.max(600 / originalImg.width, 450 / originalImg.height);
const w = originalImg.width * scale;
const h = originalImg.height * scale;
const ix = 147 + (600 - w) / 2;
const iy = 287 + (450 - h) / 2;
ctx.drawImage(originalImg, ix, iy, w, h);
} else {
// Fallback static if image not loaded properly
ctx.fillStyle = "#000000";
ctx.fillRect(147, 287, 600, 450);
}
// Screen Glass Glare
ctx.fillStyle = "rgba(255, 255, 255, 0.15)";
ctx.beginPath();
ctx.moveTo(147, 287);
ctx.lineTo(147 + 350, 287);
ctx.lineTo(147, 287 + 450);
ctx.closePath();
ctx.fill();
ctx.restore(); // Remove clip for the screen bounds
// 8. Draw Side Control Panel (Retro Buttons & Details)
const px = 847; // Center X of the side control panel
const knobOuterColor = "#f1f2f6";
const knobInnerColor = accentColor;
// Helper for rotational knobs
function drawKnob(x, y, angle) {
// Outer rim
ctx.fillStyle = knobOuterColor;
ctx.beginPath();
ctx.arc(x, y, 40, 0, Math.PI * 2);
ctx.fill();
// Inner dial
ctx.fillStyle = knobInnerColor;
ctx.beginPath();
ctx.arc(x, y, 25, 0, Math.PI * 2);
ctx.fill();
// Direction pointer
ctx.strokeStyle = knobOuterColor;
ctx.lineWidth = 6;
ctx.beginPath();
ctx.moveTo(x, y);
ctx.lineTo(x + Math.cos(angle) * 18, y + Math.sin(angle) * 18);
ctx.stroke();
}
// Knobs
drawKnob(px, 360, -Math.PI / 4); // Knob 1 (45 degrees angle)
drawKnob(px, 480, Math.PI / 6); // Knob 2
// Speaker Grid
ctx.fillStyle = knobInnerColor;
for (let dx of [-25, 0, 25]) {
for (let dy of [-30, 0, 30]) {
ctx.beginPath();
ctx.arc(px + dx, 610 + dy, 6, 0, Math.PI * 2);
ctx.fill();
}
}
// Power Indicator Light
ctx.fillStyle = "#ff4757";
ctx.beginPath();
ctx.arc(px, 720, 10, 0, Math.PI * 2);
ctx.fill();
// Power Light Glow
ctx.fillStyle = "rgba(255, 71, 87, 0.4)";
ctx.beginPath();
ctx.arc(px, 720, 20, 0, Math.PI * 2);
ctx.fill();
// Output visual Canvas
return canvas;
}
Apply Changes