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

The Archive Base Latest Questions

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

I just started to learn a little bit about canvas! I want to draw

  • 0

I just started to learn a little bit about canvas!

I want to draw rectangle that flickers (shows/hides/shows/hides/shows…) after set time interval.

If I remove setInterval() and clear_canvas() – rectangle is drown. Problem seems to be in clear_canvas(). I got that code from here.

At the moment it just shows blank page. In my opinion, it should draw, clear, draw, clear…

I addedconsole.log() for debugging; it’s called! No errors or whatever are thrown in Chrome 14 (on Fedora 15, if that matters). Everything seems to be okay; unfortunately, it isn’t!

I putted code on JsFiddle so you, guys, can help me out. Thanks!

  • 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-27T10:59:06+00:00Added an answer on May 27, 2026 at 10:59 am

    Your problem is is that it is clearing the rectangle the moment it is drawn.

    You’ll need to make the function alternate between drawing and clearing in order to notice anything.

    var draw = false;
    $(function() {
    
        setInterval(function() {
    
            console.log('called');
            if(draw)
                    draw_rectange();
            else
                    clear_canvas();
    
            draw = !draw;
    
        }, 1000);
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to learn C# and I'm a little bit confused about
I just started to learn swing by myself, I'm little bit confused why my
I just started to learn Rails from railstutorial.org. After installing Rails I cerated an
I just started to learn about mod rewrite process. Now, I got some problems
Backrground Information I've just started to learn stuff about drivers and the linux kernel.
Well, I've just started to learn Exceptions at college, here is a code that
I just started to learn Objective c. Now i want a under title (small
Well, I got problem here with opengl ES stuff (just started to learn about
I recently started using the Yii framework trying to learn a little bit more
I have just started trying to learn Git and I have got a little

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.