Please bookmark this page to avoid losing your image tool!

Image Alarm Clock

(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, frameColor = "#e74c3c", clockColor = "#ffffff", alarmTime = "07:30") {
    const canvas = document.createElement('canvas');
    canvas.width = 500;
    canvas.height = 500;
    const ctx = canvas.getContext('2d');
    
    // Parse alarm time
    const timeParts = alarmTime.split(':');
    const aH = timeParts[0] ? parseInt(timeParts[0]) : 7;
    const aM = timeParts[1] ? parseInt(timeParts[1]) : 30;
    const alarmAngle = ((aH % 12 + aM / 60) * Math.PI / 6) - Math.PI / 2;

    function draw() {
        ctx.clearRect(0, 0, 500, 500);
        
        ctx.lineCap = 'round';
        ctx.lineJoin = 'round';
        
        const now = new Date();
        const s = now.getSeconds();
        const m = now.getMinutes();
        const hrs = now.getHours();
        
        // Determine whether alarm is currently ringing
        const isAlarming = (hrs === aH && m === aM);
        
        // --- Draw Frame (Alarm Clock Shape) ---
        
        // Handle
        ctx.beginPath();
        ctx.moveTo(130, 142);
        ctx.quadraticCurveTo(250, -60, 370, 142);
        ctx.lineWidth = 14;
        ctx.strokeStyle = frameColor;
        ctx.stroke();
        
        // Bells
        ctx.beginPath();
        ctx.arc(122, 142, 45, 0, Math.PI * 2);
        ctx.arc(378, 142, 45, 0, Math.PI * 2);
        ctx.fillStyle = frameColor;
        ctx.fill();
        
        // Hammer
        let hammerShake = 0;
        if (isAlarming) {
            hammerShake = Math.sin(Date.now() / 20) * 15;
            
            // Motion lines for bells
            const shake = Math.sin(Date.now() / 20) * 4;
            ctx.beginPath();
            ctx.lineWidth = 3;
            ctx.strokeStyle = '#555555';
            ctx.moveTo(80 + shake, 110 - shake); ctx.lineTo(60 + shake, 90 - shake);
            ctx.moveTo(70 + shake, 130 - shake); ctx.lineTo(50 + shake, 110 - shake);
            ctx.moveTo(420 + shake, 110 + shake); ctx.lineTo(440 + shake, 90 + shake);
            ctx.moveTo(430 + shake, 130 + shake); ctx.lineTo(450 + shake, 110 + shake);
            ctx.stroke();
        }
        
        ctx.beginPath();
        ctx.moveTo(250, 110); // pivot
        const hammerAngle = hammerShake * (Math.PI / 180);
        const hLength = 50; 
        const hEndX = 250 + Math.sin(hammerAngle) * hLength;
        const hEndY = 110 - Math.cos(hammerAngle) * hLength;
        ctx.lineTo(hEndX, hEndY);
        ctx.lineWidth = 8;
        ctx.strokeStyle = frameColor;
        ctx.stroke();
        
        ctx.beginPath();
        ctx.arc(hEndX, hEndY, 13, 0, Math.PI*2);
        ctx.fillStyle = frameColor;
        ctx.fill();
        
        // Legs
        ctx.beginPath();
        ctx.moveTo(173, 410);
        ctx.lineTo(140, 480);
        ctx.moveTo(327, 410);
        ctx.lineTo(360, 480);
        ctx.lineWidth = 18;
        ctx.strokeStyle = frameColor;
        ctx.stroke();
        
        // Foot bases
        ctx.beginPath();
        ctx.arc(140, 480, 9, 0, Math.PI*2);
        ctx.arc(360, 480, 9, 0, Math.PI*2);
        ctx.fillStyle = frameColor;
        ctx.fill();
        
        // Main Body (Frame Box)
        ctx.beginPath();
        ctx.arc(250, 270, 160, 0, Math.PI * 2);
        ctx.fillStyle = frameColor;
        ctx.fill();
        
        // Inner white background before dial
        ctx.beginPath();
        ctx.arc(250, 270, 145, 0, Math.PI * 2);
        ctx.fillStyle = '#ffffff';
        ctx.fill();
        
        // --- Clip Image as Dial ---
        ctx.save();
        ctx.beginPath();
        ctx.arc(250, 270, 145, 0, Math.PI * 2);
        ctx.clip();
        
        if (originalImg.complete && originalImg.naturalWidth > 0) {
            const scale = Math.max(290 / originalImg.width, 290 / originalImg.height);
            const w = originalImg.width * scale;
            const h = originalImg.height * scale;
            const x = 250 - w / 2;
            const y = 270 - h / 2;
            ctx.drawImage(originalImg, x, y, w, h);
        }
        
        // Darkening overlay to make parts pop
        ctx.fillStyle = 'rgba(0, 0, 0, 0.3)';
        ctx.fillRect(100, 120, 300, 300);
        
        // Glass Reflection Glare Elements
        ctx.beginPath();
        ctx.moveTo(70, 100); ctx.lineTo(160, 100);
        ctx.lineTo(100, 450); ctx.lineTo(10, 450);
        ctx.closePath();
        ctx.fillStyle = 'rgba(255, 255, 255, 0.08)';
        ctx.fill();
        
        ctx.beginPath();
        ctx.moveTo(180, 100); ctx.lineTo(200, 100);
        ctx.lineTo(140, 450); ctx.lineTo(120, 450);
        ctx.closePath();
        ctx.fillStyle = 'rgba(255, 255, 255, 0.08)';
        ctx.fill();
        
        ctx.restore();
        
        // --- Draw Tick Marks ---
        for (let i = 0; i < 60; i++) {
            const angle = i * Math.PI / 30;
            const r1 = i % 5 === 0 ? 135 : 140;
            const r2 = 145;
            ctx.beginPath();
            ctx.moveTo(250 + Math.cos(angle) * r1, 270 + Math.sin(angle) * r1);
            ctx.lineTo(250 + Math.cos(angle) * r2, 270 + Math.sin(angle) * r2);
            ctx.lineWidth = i % 5 === 0 ? 3 : 1;
            ctx.strokeStyle = clockColor;
            ctx.stroke();
        }
        
        // --- Draw Numbers ---
        ctx.textBaseline = 'middle';
        ctx.textAlign = 'center';
        ctx.font = 'bold 28px sans-serif';
        ctx.fillStyle = clockColor;
        ctx.shadowColor = 'rgba(0,0,0,0.8)';
        ctx.shadowBlur = 4;
        ctx.shadowOffsetX = 1;
        ctx.shadowOffsetY = 1;
        
        for (let i = 1; i <= 12; i++) {
            const angle = i * Math.PI / 6 - Math.PI / 2;
            const r = 118;
            const nx = 250 + Math.cos(angle) * r;
            const ny = 270 + Math.sin(angle) * r;
            ctx.fillText(i.toString(), nx, ny);
        }
        ctx.shadowColor = 'transparent'; // clear shadow for paths
        
        // Calculate Hand Angles
        const h12 = hrs % 12;
        const sAngle = (s * Math.PI / 30) - Math.PI / 2;
        const mAngle = ((m + s / 60) * Math.PI / 30) - Math.PI / 2;
        const hAngle = ((h12 + m / 60) * Math.PI / 6) - Math.PI / 2;
        
        // Configure shadow for hands
        ctx.shadowColor = 'rgba(0,0,0,0.6)';
        ctx.shadowBlur = 5;
        ctx.shadowOffsetX = 3;
        ctx.shadowOffsetY = 3;
        
        // --- Alarm Hand ---
        ctx.beginPath();
        ctx.moveTo(250, 270);
        const alarmX = 250 + Math.cos(alarmAngle) * 75;
        const alarmY = 270 + Math.sin(alarmAngle) * 75;
        ctx.lineTo(alarmX, alarmY);
        ctx.lineWidth = 3;
        ctx.strokeStyle = '#f1c40f'; // Gold
        ctx.stroke();
        
        // Alarm Hand Arrow Tip
        ctx.beginPath();
        ctx.moveTo(alarmX + Math.cos(alarmAngle) * 10, alarmY + Math.sin(alarmAngle) * 10);
        ctx.lineTo(alarmX + Math.cos(alarmAngle + Math.PI / 2) * 5, alarmY + Math.sin(alarmAngle + Math.PI / 2) * 5);
        ctx.lineTo(alarmX + Math.cos(alarmAngle - Math.PI / 2) * 5, alarmY + Math.sin(alarmAngle - Math.PI / 2) * 5);
        ctx.closePath();
        ctx.fillStyle = '#f1c40f';
        ctx.fill();
        
        // --- Hour Hand ---
        ctx.beginPath();
        ctx.moveTo(250, 270);
        ctx.lineTo(250 + Math.cos(hAngle) * 65, 270 + Math.sin(hAngle) * 65);
        ctx.lineWidth = 9;
        ctx.strokeStyle = clockColor;
        ctx.stroke();
        
        // --- Minute Hand ---
        ctx.beginPath();
        ctx.moveTo(250, 270);
        ctx.lineTo(250 + Math.cos(mAngle) * 95, 270 + Math.sin(mAngle) * 95);
        ctx.lineWidth = 5;
        ctx.strokeStyle = clockColor;
        ctx.stroke();
        
        // --- Second Hand ---
        ctx.beginPath();
        ctx.moveTo(250, 270);
        ctx.lineTo(250 - Math.cos(sAngle) * 20, 270 - Math.sin(sAngle) * 20); // Tail
        ctx.moveTo(250, 270);
        ctx.lineTo(250 + Math.cos(sAngle) * 115, 270 + Math.sin(sAngle) * 115); // Pointer
        ctx.lineWidth = 2;
        ctx.strokeStyle = '#e74c3c'; // Always distinct red
        ctx.stroke();
        
        // Clear shadow for center dots
        ctx.shadowColor = 'transparent';
        
        // Center Dots
        ctx.beginPath();
        ctx.arc(250, 270, 7, 0, Math.PI*2);
        ctx.fillStyle = clockColor;
        ctx.fill();
        
        ctx.beginPath();
        ctx.arc(250, 270, 3, 0, Math.PI*2);
        ctx.fillStyle = '#e74c3c';
        ctx.fill();
    }
    
    // Setup draw and animation loops
    let animationId;
    function loop() {
        draw();
        animationId = requestAnimationFrame(loop);
    }
    
    // Stop sequence when removed from DOM
    const observer = new MutationObserver((mutations, obs) => {
        if (!document.body.contains(canvas)) {
            cancelAnimationFrame(animationId);
            obs.disconnect();
        }
    });
    setTimeout(() => {
        if (document.body.contains(canvas)) {
             observer.observe(document.body, { childList: true, subtree: true });
        }
    }, 1000);
    
    // Initiate clock
    if (originalImg.complete && originalImg.naturalWidth !== 0) {
        loop();
    } else {
        originalImg.onload = loop;
        originalImg.onerror = loop; // continue even if fallback error
    }
    
    return canvas;
}

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 Alarm Clock tool allows you to transform any uploaded image into the decorative face of a classic, animated twin-bell alarm clock. The tool overlays a functional clock interface—including moving hour, minute, and second hands—on top of your image, while also allowing you to set a specific alarm time that is visually represented on the dial. This tool is ideal for creating unique digital assets, personalized wallpapers, or fun, time-themed social media graphics.

Leave a Reply

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