1

Watch our latest Product Showcase

Group 370
2

Meet us at WeAreDevelopers World Congress in Berlin

Group 370
3

Spotlight Whitepaper by IDC on Importance of Automated Code Review Technologies

Group 370

HTML Canvas cheat sheet

In this article:
Subscribe to our blog:

While browsing the web for cool projects, we found the “HTML Canvas Tutorial” cheat sheet. While reading it, and thinking of ways to play with that, we reached out to Colin Cieloha, one of the guys responsible for the page, and got a few more words of advise from him. He told us:

The canvas element can be useful to professionals who have enough experience in graphic design to know what they want the HTML element to do, but it can also be a great tool for beginners to work with. People just starting off, or even experimenting, will need to understand that although a canvas element looks a lot like an ‘img’ element, it is extremely different. You no longer have to worry about the ‘src’ attribute, and all you have to do is set the ‘width’ and ‘height’ before you are on your way.

One useful feature in the canvas element that ‘img’ elements do not have is the ability to set fallback content if the content is loaded on an older browser. Fallback content can a saving grace for your content by giving the user a message that explains why the canvas element might not be loading and what they can do to fix it.

Another key difference between the canvas element and the ‘img’ element is the requirement of using a closing tag, or ‘</canvas>’. This is an important difference in the syntax which will determine whether the element works at all.

The last, and by far the most important thing, to consider is the rendering context of your content. This sounds like complex terminology, but all it means is whether you will be using your canvas for 2D or 3D content. By properly setting this using the ‘getContext’ method, you eliminate the chances of your content being displayed completely wrong.

As with anything, success in the beginning is characterized by avoiding the big mistakes. Understanding the three mistakes outlined above and how to avoid them will give beginners a huge advantage and get them to where it is possible to experiment with canvas and understand its capabilities.

Check their cheat sheet and a random cool canvas project from around the web: Solar Crusaders.

Colin Cieloha: HTML Canvas Page

Colin Cieloha is an American author and content marketer at Skilled.co. He writes about everything that will draw his attention with a focus on the mobile and e-commerce space. When he is not writing he is spending his time traveling the globe and snowboarding. You can follow him on his Twitter at @ColinCieloha or on Linkedin.

Until next time!


About Codacy

Codacy is used by thousands of developers to analyze billions of lines of code every day!

Getting started is easy – and free! Just use your  GitHub, Bitbucket or Google account to sign up.

GET STARTED

RELATED
BLOG POSTS

Lambda World With Codacy & 47 Degrees
If you are a functional programming aficionado you will be very pleased regarding our partnership for Lambda World conference.
Configurations and other new filters
Introducing code pattern configurations is among key exciting moments. Particularly as features that our users have asked in the last few months.
Christmas coding: developers DO code on holidays
According to answers to #1 and #2 questions on Quora, Christmas coding (and coding on weekends) is, indeed, real. Both Quora answers have fantastic...

Automate code
reviews on your commits and pull request

Group 13