You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, theme = "Random", randomnessSeed = 0) {
// Determine canvas dimensions
const width = 800;
const height = 600;
const canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
// 1. Draw the original image as a background (object-fit: cover)
const scale = Math.max(width / originalImg.width, height / originalImg.height);
const x = (width / 2) - (originalImg.width / 2) * scale;
const y = (height / 2) - (originalImg.height / 2) * scale;
ctx.drawImage(originalImg, x, y, originalImg.width * scale, originalImg.height * scale);
// 2. Add an overlay to darken the background
ctx.fillStyle = 'rgba(15, 15, 25, 0.75)';
ctx.fillRect(0, 0, width, height);
// 3. Add a high-tech "scanning" grid pattern
ctx.strokeStyle = 'rgba(0, 255, 200, 0.08)';
ctx.lineWidth = 1;
for (let i = 0; i < width; i += 40) {
ctx.beginPath();
ctx.moveTo(i, 0);
ctx.lineTo(i, height);
ctx.stroke();
}
for (let j = 0; j < height; j += 40) {
ctx.beginPath();
ctx.moveTo(0, j);
ctx.lineTo(width, j);
ctx.stroke();
}
// 4. Data pools for AI prompt generation
const styles = [
'Cyberpunk', 'Steampunk', 'Watercolor', 'Oil Painting', 'Synthwave',
'Origami', 'Claymation', 'Low Poly', 'Anime Concept Art', 'Surrealism',
'Gothic', 'Minimalist Vector', 'Dark Fantasy', 'Biomechanical'
];
const modifiers = [
'set in a post-apocalyptic world', 'in the style of Studio Ghibli',
'with bioluminescent lighting', 'rendered in Unreal Engine 5',
'during a golden hour sunset', 'with cosmic space elements',
'submerged underwater', 'floating in the sky', 'made entirely of glass',
'with neon noir aesthetics', 'overgrown with lush alien flora'
];
const lightings = [
'Cinematic', 'Neon', 'Volumetric', 'Golden Hour', 'Moody',
'Flat', 'Studio', 'Natural', 'Rim Lighting'
];
const moods = [
'Epic', 'Melancholic', 'Joyful', 'Mysterious', 'Dreamy',
'Aggressive', 'Ethereal', 'Ominous', 'Whimsical'
];
// Simple pseudo-random function if a >0 seed is provided, otherwise truly random
let seedCount = randomnessSeed || Math.random() * 10000;
const random = () => {
let t = seedCount += 0x6D2B79F5;
t = Math.imul(t ^ t >>> 15, t | 1);
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
const getRandomItem = (arr) => arr[Math.floor(random() * arr.length)];
const selStyle = (theme.toLowerCase() !== "random" && theme.length > 2) ? theme : getRandomItem(styles);
const selMod = getRandomItem(modifiers);
const selLight = getRandomItem(lightings);
const selMood = getRandomItem(moods);
const promptText = `A stunning ${selStyle} reimagining of this scene, ${selMod}. Feature ${selLight} lighting to create an overall ${selMood} atmosphere. Ultra-detailed, 8k resolution, highly creative.`;
// 5. Draw Title
ctx.textAlign = 'center';
ctx.fillStyle = '#ffffff';
ctx.font = 'bold 34px sans-serif';
ctx.shadowColor = 'rgba(0, 255, 200, 0.5)';
ctx.shadowBlur = 10;
ctx.fillText('AI IMAGE IDEA GENERATOR', width / 2, 70);
ctx.shadowBlur = 0; // Reset shadow for clean UI
// 6. Draw UI Card for the Idea
const cardX = 100;
const cardY = 120;
const cardW = 600;
const cardH = 380;
const cornerRadius = 15;
ctx.fillStyle = 'rgba(20, 25, 35, 0.85)';
ctx.strokeStyle = '#00ffcc';
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(cardX + cornerRadius, cardY);
ctx.lineTo(cardX + cardW - cornerRadius, cardY);
ctx.quadraticCurveTo(cardX + cardW, cardY, cardX + cardW, cardY + cornerRadius);
ctx.lineTo(cardX + cardW, cardY + cardH - cornerRadius);
ctx.quadraticCurveTo(cardX + cardW, cardY + cardH, cardX + cardW - cornerRadius, cardY + cardH);
ctx.lineTo(cardX + cornerRadius, cardY + cardH);
ctx.quadraticCurveTo(cardX, cardY + cardH, cardX, cardY + cardH - cornerRadius);
ctx.lineTo(cardX, cardY + cornerRadius);
ctx.quadraticCurveTo(cardX, cardY, cardX + cornerRadius, cardY);
ctx.closePath();
ctx.fill();
ctx.stroke();
// 7. Write Card Contents
ctx.textAlign = 'left';
// Labels & Values
const drawProperty = (label, value, yOffset) => {
ctx.font = 'bold 18px monospace';
ctx.fillStyle = '#00ffcc';
ctx.fillText(label, cardX + 40, cardY + yOffset);
ctx.font = '18px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText(value, cardX + 180, cardY + yOffset);
};
drawProperty('STYLE: ', selStyle, 50);
drawProperty('MOOD: ', selMood, 90);
drawProperty('LIGHTING:', selLight, 130);
// Separator line
ctx.beginPath();
ctx.moveTo(cardX + 40, cardY + 160);
ctx.lineTo(cardX + cardW - 40, cardY + 160);
ctx.strokeStyle = 'rgba(0, 255, 204, 0.3)';
ctx.stroke();
// The Generated Prompt Box
ctx.font = 'bold 18px monospace';
ctx.fillStyle = '#00ffcc';
ctx.fillText('GENERATED PROMPT:', cardX + 40, cardY + 200);
ctx.font = 'italic 20px sans-serif';
ctx.fillStyle = '#dddddd';
// Wrap text function
const wrapText = (context, text, x, y, maxWidth, lineHeight) => {
const words = text.split(' ');
let line = '';
let currentY = y;
for (let n = 0; n < words.length; n++) {
const testLine = line + words[n] + ' ';
const metrics = context.measureText(testLine);
const testWidth = metrics.width;
if (testWidth > maxWidth && n > 0) {
context.fillText(line, x, currentY);
line = words[n] + ' ';
currentY += lineHeight;
} else {
line = testLine;
}
}
context.fillText(line, x, currentY);
};
// Draw the prompt text within bounds
wrapText(ctx, `"${promptText}"`, cardX + 40, cardY + 240, cardW - 80, 28);
// 8. Footer Instructions
ctx.textAlign = 'center';
ctx.font = '14px sans-serif';
ctx.fillStyle = 'rgba(255, 255, 255, 0.5)';
ctx.fillText('Copy the prompt above and use it with your favorite AI image generator.', width / 2, height - 30);
return canvas;
}
Apply Changes