You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, themeColor = "#00FF41", scanPosition = 0.6) {
// Determine dimensions
const width = originalImg.width;
const height = originalImg.height;
// Create and size the canvas
const canvas = document.createElement("canvas");
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext("2d");
// Draw the initial image
ctx.drawImage(originalImg, 0, 0, width, height);
// 1. Apply RGB Chromatic Aberration (TV Glitch Effect)
const minDim = Math.min(width, height);
const shift = Math.max(1, Math.floor(minDim * 0.005)); // Proportional color shift
const imgData = ctx.getImageData(0, 0, width, height);
const data = imgData.data;
const outData = new Uint8ClampedArray(data.length);
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const index = (y * width + x) * 4;
// Shift Red right
const shiftXRed = x + shift < width ? x + shift : x;
const indexRed = (y * width + shiftXRed) * 4;
outData[index] = data[indexRed];
// Keep Green normal
outData[index + 1] = data[index + 1];
// Shift Blue left
const shiftXBlue = x - shift > 0 ? x - shift : x;
const indexBlue = (y * width + shiftXBlue) * 4;
outData[index + 2] = data[indexBlue + 2];
// Alpha
outData[index + 3] = data[index + 3];
}
}
// Put RGB shifted data back on canvas
imgData.data.set(outData);
ctx.putImageData(imgData, 0, 0);
// 2. Apply TV Scanlines
ctx.fillStyle = "rgba(0, 0, 0, 0.25)";
const scanlineHeight = Math.max(2, Math.floor(minDim * 0.005));
for (let y = 0; y < height; y += scanlineHeight * 2) {
ctx.fillRect(0, y, width, scanlineHeight);
}
// 3. Apply Vignette Effect
const gradient = ctx.createRadialGradient(
width / 2, height / 2, minDim * 0.3,
width / 2, height / 2, minDim * 0.8
);
gradient.addColorStop(0, "rgba(0, 20, 0, 0.0)");
gradient.addColorStop(1, "rgba(0, 10, 0, 0.6)");
ctx.globalCompositeOperation = "multiply";
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, width, height);
ctx.globalCompositeOperation = "source-over";
// 4. Draw HUD Elements (Identifier Target & Sound Scanner)
ctx.strokeStyle = themeColor;
ctx.fillStyle = themeColor;
ctx.lineWidth = Math.max(1, Math.floor(minDim * 0.004));
const fontSize = Math.max(10, Math.floor(minDim * 0.025));
ctx.font = `bold ${fontSize}px "Courier New", Courier, monospace`;
ctx.shadowColor = themeColor;
ctx.shadowBlur = Math.floor(minDim * 0.015);
// A. Identifier Target Brackets
const cx = width / 2;
const cy = height / 2;
const boxW = minDim * 0.4;
const boxH = boxW;
const len = boxW * 0.15; // length of the bracket arms
const drawBracket = (startX, startY, turnX, turnY, endX, endY) => {
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(turnX, turnY);
ctx.lineTo(endX, endY);
ctx.stroke();
};
// Top-Left
drawBracket(cx - boxW/2 + len, cy - boxH/2, cx - boxW/2, cy - boxH/2, cx - boxW/2, cy - boxH/2 + len);
// Top-Right
drawBracket(cx + boxW/2 - len, cy - boxH/2, cx + boxW/2, cy - boxH/2, cx + boxW/2, cy - boxH/2 + len);
// Bottom-Left
drawBracket(cx - boxW/2 + len, cy + boxH/2, cx - boxW/2, cy + boxH/2, cx - boxW/2, cy + boxH/2 - len);
// Bottom-Right
drawBracket(cx + boxW/2 - len, cy + boxH/2, cx + boxW/2, cy + boxH/2, cx + boxW/2, cy + boxH/2 - len);
ctx.fillText("TARGET IDENTIFIED", cx - boxW/2, cy - boxH/2 - fontSize);
ctx.fillText("MATCH_PROB: 99.8%", cx + boxW/2 - (fontSize * 9), cy + boxH/2 + fontSize * 1.5);
// B. Sound Scanner Waveform
const waveX = width * 0.05;
const waveW = width * 0.3;
const waveY = height * 0.85;
const waveH = height * 0.08;
ctx.fillText("SND-SCN // VOCAL FREQ ANALYZER", waveX, waveY - waveH / 2 - fontSize);
ctx.beginPath();
ctx.moveTo(waveX, waveY);
for (let i = 0; i < waveW; i++) {
// Complex pseudo-random waveform
let yOff = Math.sin(i * 0.05) * waveH * 0.4;
yOff += Math.sin(i * 0.12) * waveH * 0.3;
yOff += Math.cos(i * 0.8) * waveH * 0.2;
// Window function to taper edges
const envelope = Math.sin((i / waveW) * Math.PI);
ctx.lineTo(waveX + i, waveY + yOff * envelope);
}
ctx.stroke();
// Equalizer bars next to wave
for(let i = 0; i < 8; i++) {
const barH = (waveH * 0.3) + Math.random() * (waveH * 0.7);
ctx.fillRect(waveX + waveW + 10 + (i * (fontSize * 0.8)), waveY + waveH/2 - barH, fontSize * 0.5, barH);
}
// C. TV Icon Badge
const tvIconW = minDim * 0.06;
const tvIconH = tvIconW * 0.75;
const tvIconX = width - width * 0.05 - tvIconW;
const tvIconY = height * 0.05 + fontSize;
ctx.strokeRect(tvIconX, tvIconY, tvIconW, tvIconH);
ctx.beginPath(); // Antennas
ctx.moveTo(tvIconX + tvIconW * 0.3, tvIconY);
ctx.lineTo(tvIconX + tvIconW * 0.1, tvIconY - tvIconH * 0.4);
ctx.moveTo(tvIconX + tvIconW * 0.7, tvIconY);
ctx.lineTo(tvIconX + tvIconW * 0.9, tvIconY - tvIconH * 0.5);
ctx.stroke();
// Inner dot
ctx.fillRect(tvIconX + tvIconW * 0.4, tvIconY + tvIconH * 0.4, tvIconW * 0.2, tvIconW * 0.2);
ctx.fillText("MAIN-REC", tvIconX, tvIconY - tvIconH * 0.8);
// D. Global Scanning Laser Line
const scanPosAllowed = Math.max(0, Math.min(1, Number(scanPosition))); // Clamp between 0 and 1
const laserY = height * scanPosAllowed;
ctx.fillStyle = themeColor;
ctx.fillRect(0, laserY, width, Math.max(2, minDim * 0.005));
// Soft glow for laser
ctx.globalAlpha = 0.3;
ctx.fillStyle = "#ffffff";
ctx.fillRect(0, laserY - minDim * 0.01, width, minDim * 0.025);
ctx.globalAlpha = 1.0;
// Reset shadow
ctx.shadowBlur = 0;
return canvas;
}
Apply Changes