You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, helmetColor = '#f0f4f8', visorColor = '#00aaff', zoomFace = 1.3) {
const c = document.createElement('canvas');
const ctx = c.getContext('2d');
const w = originalImg.width;
const h = originalImg.height;
c.width = w;
c.height = h;
// Define proportional geometry based on image size
const cx = w / 2;
const cy = h / 2;
const R = Math.min(w, h) * 0.42;
const rX = R * 0.65;
const rY = R * 0.60;
const vCy = cy - R * 0.05;
// 1. Draw Space Background
ctx.fillStyle = '#050510';
ctx.fillRect(0, 0, w, h);
// Stars
for (let i = 0; i < 200; i++) {
ctx.fillStyle = `rgba(255, 255, 255, ${Math.random()})`;
ctx.beginPath();
ctx.arc(Math.random() * w, Math.random() * h, Math.random() * (R * 0.005), 0, Math.PI * 2);
ctx.fill();
}
// Cosmic Nebula effect
for (let i = 0; i < 5; i++) {
let nGrad = ctx.createRadialGradient(
Math.random() * w, Math.random() * h, 0,
Math.random() * w, Math.random() * h, R * 1.5
);
nGrad.addColorStop(0, `rgba(${Math.random() * 100 + 50}, ${Math.random() * 100}, ${Math.random() * 255}, 0.15)`);
nGrad.addColorStop(1, 'rgba(0,0,0,0)');
ctx.fillStyle = nGrad;
ctx.fillRect(0, 0, w, h);
}
// 2. Draw Space Suit / Shoulders
let torsoGrad = ctx.createLinearGradient(0, cy, 0, h);
torsoGrad.addColorStop(0, helmetColor);
torsoGrad.addColorStop(1, '#333333');
ctx.fillStyle = torsoGrad;
ctx.beginPath();
ctx.moveTo(cx - R * 0.7, cy + R * 0.6);
ctx.quadraticCurveTo(cx - R * 1.8, h * 0.9, cx - w, h);
ctx.lineTo(cx + w, h);
ctx.quadraticCurveTo(cx + R * 1.8, h * 0.9, cx + R * 0.7, cy + R * 0.6);
ctx.closePath();
ctx.fill();
ctx.strokeStyle = '#222';
ctx.lineWidth = Math.max(1, R * 0.02);
ctx.stroke();
// 3. Draw Helmet Main Dome
let domeGrad = ctx.createRadialGradient(cx - R * 0.3, cy - R * 0.3, R * 0.1, cx, cy, R);
domeGrad.addColorStop(0, '#ffffff');
domeGrad.addColorStop(0.5, helmetColor);
domeGrad.addColorStop(1, '#333344');
ctx.fillStyle = domeGrad;
ctx.shadowColor = 'rgba(0,0,0,0.6)';
ctx.shadowBlur = R * 0.1;
ctx.shadowOffsetY = R * 0.05;
ctx.beginPath();
ctx.arc(cx, cy, R, 0, Math.PI * 2);
ctx.fill();
ctx.shadowColor = 'transparent'; // Reset shadows
ctx.shadowOffsetY = 0;
// 4. Inner Helmet Interior (Backdrops the face)
ctx.fillStyle = '#111';
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 1.05, rY * 1.05, 0, 0, Math.PI * 2);
ctx.fill();
// 5. Draw the face (Original Image masked within the Visor)
ctx.save();
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 0.95, rY * 0.95, 0, 0, Math.PI * 2);
ctx.clip();
let scaleFactor = Number(zoomFace);
if (isNaN(scaleFactor) || scaleFactor < 0.1) scaleFactor = 1.3;
// Zoom in on the image perfectly centered
let sW = w / scaleFactor;
let sH = h / scaleFactor;
let sX = (w - sW) / 2;
let sY = (h - sH) / 2;
ctx.drawImage(originalImg, sX, sY, sW, sH, 0, 0, w, h);
// Inner shadow/vignette inside visor
let innerShadow = ctx.createRadialGradient(cx, vCy, rY * 0.5, cx, vCy, rY * 1.0);
innerShadow.addColorStop(0, 'rgba(0,0,0,0)');
innerShadow.addColorStop(0.7, 'rgba(0,0,0,0.5)');
innerShadow.addColorStop(1, 'rgba(0,0,0,0.9)');
ctx.fillStyle = innerShadow;
ctx.fillRect(cx - rX, vCy - rY, rX * 2, rY * 2);
ctx.restore();
// 6. Visor Borders and Frame
// Inner Rim
ctx.lineWidth = R * 0.03;
ctx.strokeStyle = '#444';
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 0.95, rY * 0.95, 0, 0, Math.PI * 2);
ctx.stroke();
// Middle Metallic Trim
ctx.lineWidth = R * 0.04;
ctx.strokeStyle = '#cda135'; // Gold accent
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 0.98, rY * 0.98, 0, 0, Math.PI * 2);
ctx.stroke();
// Outer Thick Rim
ctx.lineWidth = R * 0.06;
ctx.strokeStyle = '#222';
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 1.03, rY * 1.03, 0, 0, Math.PI * 2);
ctx.stroke();
// 7. Visor Glass Enhancements (Reflections & HUD)
ctx.save();
ctx.beginPath();
ctx.ellipse(cx, vCy, rX * 0.95, rY * 0.95, 0, 0, Math.PI * 2);
ctx.clip();
// Glossy curve highlight
ctx.fillStyle = 'rgba(255, 255, 255, 0.12)';
ctx.beginPath();
ctx.ellipse(cx, vCy - rY * 0.2, rX * 0.8, rY * 0.5, 0, Math.PI, Math.PI * 2);
ctx.quadraticCurveTo(cx, vCy, cx - rX * 0.8, vCy - rY * 0.2);
ctx.fill();
// Colored visor tint
ctx.globalCompositeOperation = 'screen';
ctx.fillStyle = visorColor;
ctx.globalAlpha = 0.25;
ctx.fillRect(cx - rX, vCy - rY, rX * 2, rY * 2);
ctx.globalCompositeOperation = 'source-over';
ctx.globalAlpha = 1.0;
// Diagonal Glass Streaks
ctx.strokeStyle = 'rgba(255, 255, 255, 0.15)';
ctx.lineWidth = R * 0.12;
ctx.beginPath();
ctx.moveTo(cx - rX, vCy - rY * 0.5);
ctx.lineTo(cx + rX * 0.5, vCy + rY);
ctx.stroke();
ctx.lineWidth = R * 0.04;
ctx.beginPath();
ctx.moveTo(cx - rX * 0.3, vCy - rY);
ctx.lineTo(cx + rX, vCy + rY * 0.5);
ctx.stroke();
// Futuristic HUD Elements overlayed on visor
ctx.shadowColor = visorColor;
ctx.shadowBlur = R * 0.02;
ctx.fillStyle = visorColor;
let fontSize = Math.max(12, R * 0.06);
ctx.font = `${fontSize}px monospace`;
ctx.fillText('REC \u25CF', cx - rX * 0.7, vCy - rY * 0.65);
ctx.fillText('SYS: OK', cx + rX * 0.2, vCy - rY * 0.65);
ctx.fillText('O2 : 98%', cx - rX * 0.7, vCy + rY * 0.75);
ctx.restore();
// 8. Helmet Details (Apparatus, Buttons, Seams)
const drawPanel = (x, y, pw, ph, col) => {
ctx.fillStyle = col;
ctx.fillRect(x, y, pw, ph);
ctx.strokeStyle = '#222';
ctx.lineWidth = Math.max(1, R * 0.005);
ctx.strokeRect(x, y, pw, ph);
};
// Jaw / Breathing filter segment
ctx.fillStyle = '#555';
ctx.beginPath();
ctx.arc(cx, cy + R * 0.8, R * 0.15, 0, Math.PI, false);
ctx.fill();
drawPanel(cx - R * 0.3, cy + R * 0.8, R * 0.2, R * 0.15, '#444');
drawPanel(cx + R * 0.1, cy + R * 0.8, R * 0.2, R * 0.15, '#444');
drawPanel(cx - R * 0.25, cy + R * 0.83, R * 0.1, R * 0.08, '#0088ff'); // Blue tech button
drawPanel(cx + R * 0.15, cy + R * 0.83, R * 0.1, R * 0.08, '#ff2200'); // Red indicator
// Collar Seam Rings
ctx.strokeStyle = '#222';
ctx.lineWidth = Math.max(2, R * 0.015);
ctx.beginPath();
ctx.arc(cx, cy, R * 1.05, Math.PI * 0.2, Math.PI * 0.8, false);
ctx.stroke();
return c;
}
Apply Changes