NEWS: Total Picture Views: 147066 | Total Article Views: 155658 | Top 5 Most Popular Article: 1. Am I Stuck Algorithm with Becker Robot | 2. How to read a JSON and work with it | 3. PickUpThings with Becker Robot | 4. Encrypted Data GUI (Download .Zip) | 5. Create Wall and Things with Becker

Canvas With Animation Javascript


In this example I will be showing how to use canvas with animation.

You can view the example at


<!DOCTYPE html>
<head lang="en">
    <meta charset="UTF-8">

    <script type="text/javascript">
        var c = 0;
        function draw(x,y){
            var can = document.getElementById("myCanvas");
            var ctx = can.getContext("2d");
            var col = ["Yellow","Red","Blue","Pink","Purple"];
            //ctx.fillStyle = "Yellow";
            ctx.fillStyle = (col[c]);
            if(x == 550){
                y+= 100;
                x = 0;
                x += 5;
            if(c > 5){
                c = 1;


            setTimeout('draw('+ x + ', ' + y + ');',40);
    <canvas height="500" width="500" id="myCanvas" style="border: 5px solid #ff0000">

    <button onclick="draw(0,0)">Draw</button>
Attachments: None

Tags: Canvas setTimeout

Total Views: 720

My name is Jean-Mathieu

I created this website so other people could enjoy finding useful stuff easier. If you have any question do not hesitate to contact me.

jean8mathieuCreated on 03/17/15


Disclosure: We are a website that needs compensation to operate like any other website on the internet.
We may receive consideration for our reviews but we are totally unbiased and do not accept paid reviews or fake reviews claiming to be something they are not.