If, as in the example image, this is a bitmap ( png , gif , jpg ... bitmap pixel images) that you are trying to copy, in fact it is very simple. In Raphael 2, you simply set the fill to point to the image file. He uses it as a background image.
If you want to crop an image or photograph using a path or Raphael shape, like a clipping mask or clip path for image files, just set the image as the fill path.
somepath.attr({fill: 'someimage.png'});
Limitations (AFAIK):
- Only one image per path
- Only one path for the image (use complex paths for complex masks)
- Things like background position are not easy - see this question for more
- I think it is impossible to stop the repetition of the image.
source share