Saturday, April 16, 2011

HTML5 Canvas element


One of the existing development on the HTML 5 is the Canvas element. HTML5 Canvas element is a miracle that allows web designers to embed interactive visual images via the HTML language. With a variety of credit attributes, providing the output is quite similar to the original web software used in the preparation of dynamic images and animation.

How does it work?

A wide assortment of methods and properties bring life into a web page using the canvas element. To draw a rectangle, gradient fill and transformation to scale and rotate, JavaScript is used. Bezier curves and arcs can also be integrated to obtain the desired interface.

Such as image tags, canvas elements using attributes such as width and height. Id is required to identify with JavaScript or other scripting language. By defining the canvas tag in this way, the layout is rendered invisible on web pages. The elements of style sheets such as borders, background colors or margins help reveal the true picture of the canvas on the screen. Standard color is always black. Tags using a color attribute to use RGB or hexadecimal value.

To create fillRect rectangular (x, y, w, h) the syntax used to create a rectangle on the screen when strokeRect (x, y, w, h) defines the use of border or stroke. fillStyle () and strokeStyle () sets form a pattern, specific colors and gradients. x and y coordinates are assigned values. The size of the value indicated by w and h. Some roads with a few strokes can be made on line beginPath () and closePath () at the beginning and end of the road. As the gradient rectangle, diagonal or other also has four arguments in which the two first shows the starting point and the last two end points of the gradient. However, the radial gradient using the six arguments where the three arguments is to circle from the starting point and the remaining three to circle for the end point. To make a straight line, moveTo () and lineTo () method is used. For character input in canvas tag, there are three attributes that can be used; fonts, textAlign, textBaseline To return the object to draw, getContext () method is used where the 2d context of the more popular methods.

Canvas Support!

Canvas elements supported by the latest versions of browsers and mobile devices such as Internet Explorer, Firefox, Safari, Chrome, Opera, iPhone and Android. In case the browser is not working with canvas and then fill fallback element is inserted in an image tag between the opening and closing tags canvas. In other words, the content is a fallback image file that will be displayed if the canvas element is not supported in the browser. JavaScript uses document.addEventListener (DOMContentLoaded) syntax to load the page.

HTML5 Canvas element most prominently used for animations and moving objects. It is somewhat inevitable to display static images. Needs dynamic output every hour and every day throughout the year targeted by the canvas tag. canvas tag is often used by websites that run on JavaScript. Compared with Adobe Flash, it loads fast and has become the latest craze on the world wide web.

Source: www.enzinearticles.com

No comments:

Post a Comment