How can I change the image of the fabric.Image
object attribute src, if I have already made an animation?
You can use .setElement()
to change the image.
For example, let's say you have a fabricJS image object called myFabricObect
.
Then, if you have an html image element <img id="newImage">
on your page, you can load your myFabricObject
with the "newImage"
like this:
myFabricObject.setElement(document.getElementById("newImage"));
You could also create a javascript Image()
and assign that to myFabricObject
:
var img=new Image();
img.onload=function(){
myFabricObject.setElement(img);
}
img.src="myNewImage.png";