Please bookmark this page to avoid losing your image tool!

Image Laugh Player Tool

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
function processImage(originalImg, laughText = "Ha ha ha ha ha! Oh, that's hilarious! Ha ha ha!", intensity = 15) {
    // Create the main wrapper container
    const wrapper = document.createElement('div');
    wrapper.style.display = 'inline-flex';
    wrapper.style.flexDirection = 'column';
    wrapper.style.alignItems = 'center';
    wrapper.style.gap = '15px';
    wrapper.style.padding = '20px';
    wrapper.style.backgroundColor = '#f7f9fc';
    wrapper.style.border = '2px dashed #a0aec0';
    wrapper.style.borderRadius = '12px';
    wrapper.style.fontFamily = 'system-ui, -apple-system, sans-serif';

    // Create the title and instructions
    const title = document.createElement('div');
    title.innerHTML = '😂 <strong>Image Laugh Player</strong> (Смех Плеер)<br><span style="font-size: 0.9em; color: #4a5568;">Click the image to play!</span>';
    title.style.textAlign = 'center';
    title.style.color = '#2d3748';

    // Set up the canvas for rendering the image and animation
    const canvas = document.createElement('canvas');
    canvas.width = originalImg.width;
    canvas.height = originalImg.height;
    canvas.style.maxWidth = '100%';
    canvas.style.boxShadow = '0 4px 6px rgba(0,0,0,0.1)';
    canvas.style.borderRadius = '8px';
    canvas.style.cursor = 'pointer';
    canvas.style.transition = 'transform 0.2s ease-in-out';

    // Simple interaction effects
    canvas.addEventListener('mouseenter', () => canvas.style.transform = 'scale(1.02)');
    canvas.addEventListener('mouseleave', () => canvas.style.transform = 'scale(1)');

    const ctx = canvas.getContext('2d');

    let isLaughing = false;
    let hasLaughed = false;
    const shakeIntensity = Number(intensity) || 15;

    // The animation render loop
    function renderFrame() {
        ctx.clearRect(0, 0, canvas.width, canvas.height);

        if (isLaughing) {
            // Calculate a wave oscillation phase based on current time
            const phase = Date.now() / 30; // Speed of the shake
            const scaleX = 1 + (shakeIntensity / 200) * Math.sin(phase);
            const scaleY = 1 + (shakeIntensity / 200) * Math.cos(phase * 1.2);
            const rotation = (shakeIntensity / 100) * Math.sin(phase * 0.8) * 0.1;

            ctx.save();
            ctx.translate(canvas.width / 2, canvas.height / 2);
            ctx.scale(scaleX, scaleY);
            ctx.rotate(rotation);
            ctx.drawImage(originalImg, -canvas.width / 2, -canvas.height / 2);
            ctx.restore();
            
            // Sustain the animation loop while laughing
            requestAnimationFrame(renderFrame);
        } else {
            // Draw static base image
            ctx.drawImage(originalImg, 0, 0);

            // Give a visual prompt if it hasn't been played yet
            if (!hasLaughed) {
                ctx.fillStyle = 'rgba(0, 0, 0, 0.35)'; // Dark overlay
                ctx.fillRect(0, 0, canvas.width, canvas.height);

                ctx.fillStyle = 'white';
                const fontSize = Math.max(20, Math.min(canvas.width / 10, 60));
                ctx.font = `bold ${fontSize}px sans-serif`;
                ctx.textAlign = 'center';
                ctx.textBaseline = 'middle';
                
                // Add a cute drop shadow for the prompt text
                ctx.shadowColor = 'rgba(0,0,0,0.8)';
                ctx.shadowBlur = 10;
                ctx.fillText('â–¶ LAUGH', canvas.width / 2, canvas.height / 2);
                
                // Reset shadow values
                ctx.shadowColor = 'transparent';
                ctx.shadowBlur = 0;
            }
        }
    }

    // Initial render
    renderFrame();

    // Event listener to trigger sequence
    canvas.addEventListener('click', () => {
        if (isLaughing) return; // Ignore clicks if already playing
        
        isLaughing = true;
        hasLaughed = true;
        renderFrame(); // Starts the requestAnimationFrame loop

        if ('speechSynthesis' in window) {
            window.speechSynthesis.cancel(); // Stop any pending speech
            const utterance = new SpeechSynthesisUtterance(laughText);
            
            // Adjust pitch/rate to sound a bit more cartoonish or manic
            utterance.pitch = 1.4;
            utterance.rate = 1.2;

            utterance.onend = () => { 
                isLaughing = false; 
                renderFrame(); // Ensure static frame is drawn
            };
            utterance.onerror = () => { 
                isLaughing = false;
                renderFrame();
            };

            window.speechSynthesis.speak(utterance);

            // Fallback timeout in case onend fails to fire in some browsers
            setTimeout(() => { 
                if (isLaughing) { 
                    isLaughing = false; 
                    renderFrame(); 
                } 
            }, 8000);
            
        } else {
            // Fallback if built-in speech synthesis is unsupported
            setTimeout(() => { 
                isLaughing = false; 
                renderFrame(); 
            }, 3000);
        }
    });

    wrapper.appendChild(title);
    wrapper.appendChild(canvas);

    // Prompt browser to asynchronously pre-load voices to avoid lag on first click
    if ('speechSynthesis' in window) {
        window.speechSynthesis.getVoices();
    }

    return wrapper;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

The Image Laugh Player Tool is an interactive utility that adds a humorous animation and audio effect to any uploaded image. When a user clicks on the image, it triggers a visual shaking animation combined with synthesized laughter text. This tool is ideal for creating funny memes, engaging social media content, or adding lighthearted, interactive elements to digital presentations and websites.

Leave a Reply

Your email address will not be published. Required fields are marked *