Friday 30 January 2015

Great HTML5 Interview Questions and Answers (Part2) | atozIQ

11. Which methods are used to draw a straight line on a Canvas?
Following methods are used to draw a straight line on a Canvas:
- moveTo(x,y) – It defines the starting co-ordinates of the line
- lineTo(x,y) – It defines the ending co-ordinates of the line
- The actual line is drawn with the help of a method like stroke()

12. What are gradients in Canvas used for? What are their different types?
Gradients in canvas are used to fill rectangles, circles, lines etc.
The gradients in Canvas are of two types: 
- createLinearGradient(x,y,x1,y1) – It creates a linear gradient
- createRadialGradient(x,y,r,x1,y1,r1) – It creates a radial/circular gradient

13. Which method is used to draw an image on the canvas?
drawImage(image,x,y) method is used to draw an image on the canvas.

14. HTML 5 provides drag and drop facility. How do you make an image draggable?
To make an image draggable, the draggable attribute is set to true:
<img draggable="true">

15. Can HTML 5 get the geographical position of a user?
- Yes, HTML 5 can get the location of a user with the use of Geolocation API.
- Use getCurrentPosition() method to get the user’s current position.
More Questions & Answers :-
Part1  Part2  Part3  Part4  Part5  Part6  Part7  Part8  Part9  Part10

No comments:

Post a Comment