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 7438917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:37:38+00:00 2026-05-29T10:37:38+00:00

Goal: I am trying to create a slightly dynamic page animated with basic canvas

  • 0

Goal: I am trying to create a slightly dynamic page animated with basic canvas animations using setInterval(). When the user first goes to the page, a background image displays. Then a canvas appears over it and gradually the opacity increases to completely opaque black. After the canvas is black, I want white text to appear over my black canvas.

Problem: The canvas transition and the text appear at the same time.

I have researched this issue, and there appears to be a panoply of solutions here. I have already tried many variations in my own code. Once I had two separate functions. Another time I tried calling a function which then called both functions in succession. I read a blog about creating an array of functions, and then looping through the functions. That idea is intriguing, but I am wondering if there is something much more simple here that will suffice.

I was working with it on jsfiddle, but the website is not cooperating at the moment. So here is what I have right now:

<div id="container">
    <a href="#" id="LftButton"><img src="imageFiles/arrowButtonLft.png" /></a>
    <a href="#" id="RtButton"><img src="imageFiles/arrowButtonRt.png" /></a>
    <div id="canvasWrapper">
        <canvas id="myCanvas" width="675" height="600">
            <p>Your browser doesn't support canvas.</p>
        </canvas>
        <script src="aboutMeScript.js" type="text/javascript"></script>
    </div>
</div>

#myCanvas{
width:675px;
height:600px;
float:left;
}
#canvasWrapper{
width:675px;
height:600px;
margin:auto;
}
#RtButton{
    float:right;
margin-right:34px;
}
#LftButton{
    float:left;
margin-left:34px;
}
#RtButton, #LftButton{
margin-top:200px;
}

var drawing = document.getElementById("myCanvas");
//Initialize drawing context
var ctx = drawing.getContext("2d");
//Canvas commands follow
var alphaCounter = .033;

function fadeCanvas(){
ctx.fillStyle = "rgba(0,0,0," + alphaCounter + ")";
ctx.fillRect(0,0,675,600);
alphaCounter += .03;
}
function display411(){
ctx.fillStyle=('#fff');
ctx.font='bold 14px + "Courier New, Courier, monospace" +';
ctx.fillText('Click the arrow keys forward to reveal the bigger picture.', 100,100);
}
function init(){
setInterval(fadeCanvas,100);
ctx.save();
setTimeout(display411(), 5000)
}
window.onload = init();

Thoughts?

  • 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-29T10:37:38+00:00Added an answer on May 29, 2026 at 10:37 am

    You have two problems.
    1. as another commentor has mentioned, your setTimeout call was incorrect
    2. Even if you correct the setTimeout call, the fadeCanvas() interval will immediately overwrite whatever text you display.

    In my opinion, the best approach is to test for 100% opacity within fadeCanvas(), and once that goal is reached, clear the interval and call display411() directly.

    function fadeCanvas(){
        ctx.fillStyle = "rgba(0,0,0," + alphaCounter + ")";
        ctx.fillRect(0,0,675,600);
        alphaCounter += .03;
        if (alphaCounter >= 1) {
            clearInterval(fadeToBlack);
            display411();
        }
    }
    
    function init(){
        fadeToBlack = setInterval(fadeCanvas,100);
        ctx.save();
        //setTimeout(display411(), 5000) 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to set up integration tests using the AbstractTransactionalJUnit4SpringContextTests base class. My goal
Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
Background / Goal More or less, I'm trying to create a nested group of
I'm trying to create a simple STRIPS -based planner. I've completed the basic functionality
I'm trying to create an user interface like the one is presented in App
I am trying to create a multi dimensional array using this syntax: $x[1] =
I'm trying to create a small app for users to have contacts. I'm using
Goal I am trying to create a port (Macports) for an open source tool
I'm trying to create a simple function to do a status test. Goal is
I am a Clojure n00b trying to create some XML strings. My goal is

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.