简体   繁体   中英

Clip area and set canvas background in Fabric.js

I am clipping canvas area, at the end i want to set clip to null and then set background to image but it's not working ,

canvas.clipTo = null;

var backgrounimage="images/tee.png";
    canvas.setBackgroundImage(backgrounimage, function() {
  canvas.renderAll();
});

Is there any way to restrict user to draw in particular area after setting background image?

This way it works — first clip is set to null then the background is set:

var backgrounimage = "images/tee.png";
canvas.setBackgroundImage(backgrounimage, function() {
  canvas.clipTo = null;
  canvas.renderAll();
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM