Painting using Canvas and JS.
Lately I've been playing around with HTML5 and Canvas trying to render icons and graphics without the use of image files. This blog post is simply showing how to render the HTML5 logo using only code. First up, we create a HTML5 canvas-tag where our logo will live. I’ll add some simple CSS to it for good measure, creating a circular form for our logo. We make sure to call our function rendering the logo as the page is loaded. <canvas id="xpCanvasWeb" class="testblock" width="175" height="175"></canvas> <style type="text/css"> .testblock { background: none repeat scroll 0 0 #2a2a2e; border: 1px solid #2a2a2e; border-radius: 115px; margin: 10px; } </style> Now, for the rendering-function, please see my inline code. My approach towards this is to paint the logo in «layers», starting with the background and adding on layer by layer until the logo is complete. By using semi-transpare...