Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6842471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:06:16+00:00 2026-05-27T00:06:16+00:00

Maybe I am asking the wrong question completely. I have read quite a bit

  • 0

Maybe I am asking the wrong question completely. I have read quite a bit and seen quite a bit of HTML 5 capabilities; however, I have not yet had time to sit down and really start utilizing any of it yet :(, but hope to soon.

Anyway, I was curious if I could do the following with HTML5 and how to begin to implement it. Or, if this does not work, then how can I make it work?

I have a popcorn image (1 piece of popped popcorn that is).

I wanted to create a canvas and on a button click, start a chain of this image being randomly “popped” onto the canvas, slowly at first then gaining speed until such time there should be a stopping point.

Anyone who has popped popcorn can understand what I am looking to do here.

Is this possible to do easily?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:06:16+00:00Added an answer on May 27, 2026 at 12:06 am

    I’ve popped popcorn and, yep, you can do this. Load the popcorn image by creating an Image object and setting its src attribute. Use the image’s onload property to start the animation. Given the animation’s duration k, use a sine curve, sin(x/(k/π)), to calculate the number of kernels to show per frame.

    Here’s one way of doing it, demo here: http://jsfiddle.net/uyk63/8/

    var IMAGE_URL = 'http://i.istockimg.com/file_thumbview_approve/959519/2/stock-photo-959519-isolated-single-popcorn.jpg';
    var DURATION = 10 * 1000, FRAMES = 30, KERNELS = 10;
    
    var canvas = document.getElementById('canvas');
    var ctx = canvas.getContext('2d');
    
    var frame = 0,
        start = new Date().getTime(),
        image = new Image;
    image.src = IMAGE_URL;
    image.onload = function() {
    
        function pop() {
            ctx.drawImage(image,
                Math.floor(Math.random() * canvas.width),
                Math.floor(Math.random() * canvas.height),
                100, 50);
        }
    
        // A little overcomplicated. You could probably do this in a single loop.
        // (It's late and I'm tired, though. Sorry.)
        function animate() {
            var i, delay,
                count = Math.floor(Math.sin(frame / (FRAMES / Math.PI)) * KERNELS);  
            for (i = 0; i < count; i++) {
                delay = (DURATION / FRAMES) / count * i;
                setTimeout(pop, delay);
            }
            if (++frame < FRAMES) {
                setTimeout(animate, DURATION / FRAMES);
            }
        }
        animate();
    
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I'm asking the wrong question, but I can't seem to find what I'm
Maybe I am asking the wrong question here. what I'm trying to do: multiple
Apparently I was asking the wrong question in my earlier post. I have a
I may be asking the wrong question here, I'm willing to change it if
My problem is a bit hairy, and I may be asking the wrong questions,
I'm new to XML validation using .xsd files. Maybe I'm not even asking the
Maybe I just don't know .NET well enough yet, but I have yet to
Maybe this is an overarching question as I've seen similar bugs in Firefox and
I may be doing everything wrong and I have the feeling that the question
I may be asking the wrong question here, and I'm open to that, so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.