Is it possible to spread an image inside html5 canvas..
like say I have 2,3 shapes..like a rectangle a circle and some squares and some random un proportional shape..
and I have a list of images..they are textures not exactly colors just textures and If I click on one I want it to spread inside any shape(transform itself accordingly without distorting the finish)
probably by mapping co-ordinates and then spreading the image or multiplying it..
Is there any way to do so??
inside html5 canvas of course
it’s a little tough to explain but if anyone has any idea about this then some pointers would be nice..
Regards,
Ashish
First, you have to save the coordinates of your shapes and hit test your mouse clicks to find matches.
To fill a shape with an image, use the createPattern function with parameter ‘repeat’. Define the fillstyle property to your pattern, and fill according to the coordinates of your shape.
Links that can be helpful :
http://www.tutorialspoint.com/html5/canvas_pattern_shadow.htm
http://simonsarris.com/blog/140-canvas-moving-selectable-shapes