Html5 Canvas | Lessoncup Programming Blog

Saturday, 16 April 2016

Html5 Canvas

Hi in this tutorial we will learn about Html5 Canvas, the canvas is a html5 new feature use to draw Graphics on webpages using JavaScript, you can start drawing using <canvas> element but you must know about JavaScript The Canvas html element have only two attributes width and height

and we can style the canvas element using CSS Style Sheets. The canvas feature supports all major browsers, using canvas feature we can draw 2d graphics like shapes, lines, text, image compositions and simple animations, gradients, The Html Canvas is a two dimensional grid X and Y

What is Best in HTML5 Canvas

The Canvas element is fully user friendly like other html elements and it is interact with all events like Mouse and Keyboard

We can easily manage the Canvas element with JavaScript code and it is very flexible to create anything using Canvas like graphics shapes and gradients

Once you built any Canvas application you can reuse in other applications like Flash

We can built 2d and 3d Games

Web based Animated banner ads without using any Flash Content

Rendering Contexts, every HTML5 Canvas element have contexts and contexts tell what Html5 Canvas API you using

Creating Canvas Element

<canvas id="myCanvas" width="600" height="300">

    <p>Your browser doesn’t support HTML5 Canvas. 
    Please check canvas for information on 
    browser support for canvas.</p>


Find the Canvas Using JavaScript

You can Access the Html elements using JavaScript

var myCanvas = document.getElementById("myCanvas");


Creating a Drawing Object

for creating drawing object 2d or 3d use getContext() object this object have methods and properties

var myCanvas = document.getElementById("myCanvas");

var draw = myCanvas.getContext("2d");


Drawing Simple Rectangle 

the bellow code draw a Rectangle the fillStyle() property used to fill the color and fillRect() property used to draw a shape with given values this method have four properties X position Y position Width and Height

var canvas = document.getElementById("myCanvas");

var draw = canvas.getContext("2d");

draw.fillStyle = "#F60";




  1. Here i had read the content you had posted. It is much interesting so please keep update like this.School web design uk

    1. Great Article Image Processing Projects

      Deep Learning Projects for Final Year

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Hi, Really great effort. Everyone must read this article. Thanks for sharing.

  3. Great, Keep it up! I really like your writing skills.

  4. Quickly drawn by essayist's restrictive method for composing.

  5. Thank you for your suggestion. I was searching like this about two days.
    online classified ads platform in Bangladesh

  6. Thank you for some other informative blog. Where else could I get that type of information written in such an ideal means? I have a mission that I’m just now working on, and I have been at the look out for such information.
    Buy Facebook Page Likes India

  7. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.

  8. It is a great website.. The Design looks very good.. Keep working like that!.

  9. Love to read it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks.

  10. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.
    สมัคร ufa

  11. Wow i can say that this is another great article as expected of this blog.Bookmarked this site..

  12. This is really a nice and informative, containing all information and also has a great impact on the new technology. Thanks for sharing it,
    roofing supplies Utah

  13. Nice to read your article! I am looking forward to sharing your adventures and experiences.

  14. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading.
    edgewood landscape

  15. Great survey, I'm sure you're getting a great response.
    moes pizza

  16. Hello! Nice website admin Zoe is my name. I'm a social media marketing director with three years of expertise in the fields of social media marketing and SEO. I build websites and POS software, and I previously worked as a digital sales manager in a POS company, where I converted leads into sales. I also have experience with brand marketing.

  17. It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks.
    Hifz Quran for adults

  18. An interesting dialogue is price comment. I feel that it is best to write more on this matter, it may not be a taboo topic however usually individuals are not enough to talk on such topics. To the next. Cheers.
    best press release services

  19. Exactly, you're very kind of us about comment!.
    haircut raleigh nc

  20. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.
    mobile accessories online shopping cash on delivery

  21. Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!
    milwaukee trash schedule

  22. Your work is very good and I appreciate you and hopping for some more informative posts. Thank you for sharing great information to us.
    telegram smm

  23. Its a great pleasure reading your post.Its full of information I am looking for and I love to post a comment that "The content of your post is awesome" Great work.
    sky camp roof top tent

  24. Thanks For sharing this Superb article.I use this Article to show my assignment in is useful For me Great Work.
    cbd north carolina

  25. I found your this post while searching for some related information on blog search...Its a good post..keep posting and update the information.
    kitchen remodeling companies

  26. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.

  27. Modern businesses are discovering that neon flex lighting can be used to create more than just open signs. The trendy neon word lights are used in co-working spaces; neon wall art is a common sight in bars, coffee shops restaurant, restaurants, and dining establishments neon signs with lights are found in beauty salons and barber shops. Neon quotes are seen in yoga studios, nightclubs, and even yoga studios.

  28. I really enjoyed reading this post, big fan. Keep up the good work andplease tell me when can you publish more articles or where can I read more on the subject?
    front window tint


Mohammad Khasim
Blogger | Web Developer
Hyderabad - INDIA

Web Development Tools | CMS | Frameworks | SEO

Get my Latest Lessons