You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, detected = "true", virusName = "ВИРУС НА ПК", scanColor = "#00FF00") {
const isVirus = (detected.toString().toLowerCase() === "true");
// Create HTML5 canvas
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
const w = originalImg.naturalWidth || originalImg.width || 800;
const h = originalImg.naturalHeight || originalImg.height || 600;
canvas.width = w;
canvas.height = h;
// 1. Fill solid background (for transparent images) & draw base image
ctx.fillStyle = "#000000";
ctx.fillRect(0, 0, w, h);
ctx.drawImage(originalImg, 0, 0, w, h);
// 2. Extract image data to generate a predictable seed based on image contents
let fallbackSeed = 12345;
try {
const imgData = ctx.getImageData(0, 0, Math.min(w, 100), Math.min(h, 100)).data;
for (let i = 0; i < imgData.length; i += 40) {
fallbackSeed += imgData[i];
}
} catch (e) {
// Fallback if blocked by CORS constraints
fallbackSeed = (w * h) % 99999;
}
let seed = fallbackSeed;
function pseudoRandom() {
seed = (seed * 9301 + 49297) % 233280;
return seed / 233280;
}
// 3. Apply glitch effect if a virus is flagged
if (isVirus) {
const glitchSlices = Math.floor(pseudoRandom() * 10) + 5;
for (let i = 0; i < glitchSlices; i++) {
const gy = pseudoRandom() * h;
const gh = pseudoRandom() * (h * 0.1);
const gxOffset = (pseudoRandom() - 0.5) * (w * 0.15);
ctx.drawImage(originalImg, 0, gy, w, gh, gxOffset, gy, w, gh);
}
// Add random corrupted color cache blocks
for (let i = 0; i < 3; i++) {
ctx.fillStyle = pseudoRandom() > 0.5 ? "rgba(255,0,0,0.3)" : "rgba(0,255,0,0.3)";
ctx.fillRect(pseudoRandom() * w, pseudoRandom() * h, pseudoRandom() * (w * 0.2), pseudoRandom() * (h * 0.1));
}
}
// 4. Draw darkening matrix/terminal tint over the image
ctx.fillStyle = "rgba(0, 15, 5, 0.65)";
ctx.fillRect(0, 0, w, h);
// 5. Draw scanner targeting grid
ctx.strokeStyle = "rgba(0, 255, 0, 0.15)";
ctx.lineWidth = 1;
const gridSize = Math.max(20, Math.floor(w / 20));
ctx.beginPath();
for (let x = 0; x < w; x += gridSize) {
ctx.moveTo(x, 0); ctx.lineTo(x, h);
}
for (let y = 0; y < h; y += gridSize) {
ctx.moveTo(0, y); ctx.lineTo(w, y);
}
ctx.stroke();
// 6. Draw scanning beam (simulated fade gradient using overlapping boxes)
const scanY = h * (0.2 + pseudoRandom() * 0.6); // Lock scanning line somewhere deterministically
ctx.fillStyle = scanColor;
const beamHeight = h * 0.2;
const slices = 20;
for(let i = 0; i < slices; i++) {
const sliceY = scanY - beamHeight + (beamHeight / slices) * i;
if(sliceY >= 0) {
ctx.globalAlpha = (i / slices) * 0.2;
ctx.fillRect(0, sliceY, w, beamHeight / slices);
}
}
// Solid line at scanner head
ctx.globalAlpha = 0.7;
ctx.fillRect(0, scanY, w, Math.max(3, h * 0.005));
ctx.globalAlpha = 1.0;
// 7. Render system scan text logs UI (Top Left)
const fontSize = Math.max(12, Math.floor(w / 35));
ctx.font = `bold ${fontSize}px "Courier New", Consolas, monospace`;
ctx.fillStyle = scanColor;
ctx.textAlign = "left";
ctx.textBaseline = "top";
const lines = [
"[sys] SYSTEM_SCAN_INITIALIZED",
"[sys] ANALYZING_PIXEL_MATRIX...",
"[sys] EXTRACTING_META_DATA...",
`[vsc] HEURISTIC_ENGINE_v${Math.floor(pseudoRandom()*9)+1}.${Math.floor(pseudoRandom()*99)}`
];
if (isVirus) {
lines.push("[wrn] ANOMALY_DETECTED_IN_SECTOR_" + Math.floor(pseudoRandom()*999));
lines.push(`[err] SIGNATURE_MATCH: ${virusName.toUpperCase()}`);
} else {
lines.push("[msg] NO_ANOMALIES_DETECTED");
lines.push("[msg] SYSTEM_IS_SECURE");
}
let textY = fontSize;
lines.forEach(line => {
ctx.fillText(line, fontSize, textY);
textY += fontSize * 1.5;
});
// Render info (Top Right)
ctx.textAlign = "right";
ctx.fillText(`TARGET DIM: ${w}x${h}`, w - fontSize, fontSize);
ctx.fillText(`SCAN HASH: 0x${Math.floor(pseudoRandom()*0xFFFFFFFF).toString(16).toUpperCase()}`, w - fontSize, fontSize * 2.5);
ctx.fillText(`CHK: OK`, w - fontSize, fontSize * 4);
// 8. Output Visual Results
if (isVirus) {
// Draw bounding boxes around "Threats"
ctx.strokeStyle = "red";
ctx.lineWidth = Math.max(2, Math.floor(w / 250));
const numBoxes = Math.floor(pseudoRandom() * 3) + 2;
for (let i = 0; i < numBoxes; i++) {
const bx = pseudoRandom() * (w * 0.8) + (w * 0.05);
const by = pseudoRandom() * (h * 0.8) + (h * 0.05);
const bw = pseudoRandom() * (w * 0.2) + w * 0.05;
const bh = pseudoRandom() * (h * 0.2) + h * 0.05;
const cornerLen = Math.min(bw, bh) * 0.2;
// Bracket corners
ctx.beginPath();
ctx.moveTo(bx, by + cornerLen); ctx.lineTo(bx, by); ctx.lineTo(bx + cornerLen, by);
ctx.moveTo(bx + bw - cornerLen, by); ctx.lineTo(bx + bw, by); ctx.lineTo(bx + bw, by + cornerLen);
ctx.moveTo(bx + bw, by + bh - cornerLen); ctx.lineTo(bx + bw, by + bh); ctx.lineTo(bx + bw - cornerLen, by + bh);
ctx.moveTo(bx + cornerLen, by + bh); ctx.lineTo(bx, by + bh); ctx.lineTo(bx, by + bh - cornerLen);
ctx.stroke();
// Threat identifier label
ctx.fillStyle = "red";
ctx.textAlign = "left";
const fontS = Math.max(10, Math.floor(w / 45));
ctx.font = `bold ${fontS}px "Courier New", Consolas, monospace`;
const threatId = Math.floor(pseudoRandom() * 9000) + 1000;
ctx.fillText("THREAT_" + threatId, bx, by - fontS * 0.5);
}
// Massive Center Alert (VIRUS DETECTED)
const alertH = Math.max(60, h * 0.2);
const alertY = (h - alertH) / 2;
ctx.fillStyle = "rgba(200, 0, 0, 0.85)";
ctx.fillRect(0, alertY, w, alertH);
// Warning bar borders
ctx.strokeStyle = "white";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(0, alertY); ctx.lineTo(w, alertY);
ctx.moveTo(0, alertY + alertH); ctx.lineTo(w, alertY + alertH);
ctx.stroke();
// Alert text
ctx.fillStyle = "white";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
const bigFont = Math.max(20, Math.floor(w / 12));
ctx.font = `bold ${bigFont}px "Courier New", Consolas, monospace`;
ctx.fillText("VIRUS DETECTED", w / 2, alertY + alertH * 0.35);
const subFont = Math.max(14, Math.floor(w / 25));
ctx.font = `bold ${subFont}px "Courier New", Consolas, monospace`;
ctx.fillText(`TYPE: ${virusName}`, w / 2, alertY + alertH * 0.70);
} else {
// Massive Center Alert (SYSTEM CLEAN)
const alertH = Math.max(60, h * 0.15);
const alertY = (h - alertH) / 2;
ctx.fillStyle = "rgba(0, 150, 0, 0.85)";
ctx.fillRect(0, alertY, w, alertH);
ctx.strokeStyle = "white";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(0, alertY); ctx.lineTo(w, alertY);
ctx.moveTo(0, alertY + alertH); ctx.lineTo(w, alertY + alertH);
ctx.stroke();
ctx.fillStyle = "white";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
const bigFont = Math.max(20, Math.floor(w / 12));
ctx.font = `bold ${bigFont}px "Courier New", Consolas, monospace`;
ctx.fillText("SYSTEM CLEAN", w / 2, h / 2);
}
return canvas;
}
Apply Changes