I load an image, then using canvas I crop it into individual squares. How can I assign the cropped selections (which are drawn on a canvas) into individual div elements? I understand that i can create multiple canvases and insert them inside multiple divs, but that would hurt the performance.
Any way of taking a canvas and converting it into an image object or something similar?
I load an image, then using canvas I crop it into individual squares. How
Share
Have you tried to use
canvas.toDataURL()to set the image of your canvas as thebackground-imageof your<div>s ?If it works, you should be able to use the image of the canvas as a CSS sprite.