You can edit the below JavaScript code to customize the image tool.
Apply Changes
function processImage(originalImg, saturationPercent = 150, warmthLevel = 50, funItemsCount = 20) {
const canvas = document.createElement('canvas');
const width = originalImg.width;
const height = originalImg.height;
// Return empty canvas if original image is not loaded properly
if (width === 0 || height === 0) return canvas;
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');
// Parse parameters
const sat = parseFloat(saturationPercent) || 150;
const warmth = Math.min(100, Math.max(0, parseFloat(warmthLevel) || 50));
const count = parseInt(funItemsCount) || 20;
// Apply baseline filters to make the image vibrant and "not boring"
ctx.filter = `saturate(${sat}%) brightness(110%) contrast(115%)`;
ctx.drawImage(originalImg, 0, 0, width, height);
ctx.filter = 'none';
// Add a warm, colorful "sunshine" gradient overlay (mimicking a beautiful, fun day)
if (warmth > 0) {
const alpha = warmth / 200; // max 0.5 opacity to prevent fully masking the image
const gradient = ctx.createLinearGradient(0, 0, width, height);
gradient.addColorStop(0, `rgba(255, 170, 0, ${alpha})`); // Sunny orange
gradient.addColorStop(0.5, `rgba(255, 100, 200, ${alpha * 0.8})`); // Vibrant pinkish tone
gradient.addColorStop(1, `rgba(0, 200, 255, ${alpha * 0.9})`); // Clear sky blue
// Overlay composite works great for vibrant color tints
ctx.globalCompositeOperation = 'overlay';
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, width, height);
// Reset composite operation for the next steps
ctx.globalCompositeOperation = 'source-over';
}
// Scatter "fun" emoji items across the canvas to bring the "Нескучный день" theme to life
if (count > 0) {
const emojis = ['☀️', '✨', '🎉', '🌈', '😎', '🎈', '🍹', '🎵'];
for (let i = 0; i < count; i++) {
const emoji = emojis[Math.floor(Math.random() * emojis.length)];
// Random positions across the canvas
const x = Math.random() * width;
const y = Math.random() * height;
// Scale emoji size relative to image size, bounded between 20px and 250px
const baseSize = Math.max(width, height) * 0.08;
const size = Math.max(20, Math.min(250, baseSize * (0.5 + Math.random())));
ctx.font = `${size}px sans-serif`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.save();
ctx.translate(x, y);
// Apply a slight random rotation to each item (-45 to +45 degrees roughly)
ctx.rotate((Math.random() - 0.5) * Math.PI / 1.5);
// Add a subtle shadow to make the elements pop off the background
ctx.shadowColor = 'rgba(0,0,0,0.4)';
ctx.shadowBlur = Math.max(5, size * 0.1);
ctx.shadowOffsetX = size * 0.05;
ctx.shadowOffsetY = size * 0.05;
ctx.fillText(emoji, 0, 0);
ctx.restore();
}
}
return canvas;
}
Apply Changes