将图像拉伸到画布中的四边形?

问题描述

是否可以在 canvas 2d API 中将图像绘制到任意四边形?

我看到 drawImage 可以让我绘制一个矩形。

ctx.drawImage(someImage,x,y,width,height);

旋转让我旋转它。

ctx.rotate(angle);
ctx.drawImage(someImage,...);

但是是否可以选择任意 4 个点来映射图像矩形的原始 4 个点?

drawImageto4Points(
  image,topLeftX,topLeftY,// location to place the topLeft of the image
  topRightX,topRightY,// location to place the topRight of the image
  bottomLeftX,bottomLeftY,// location to place the bottomLeft of the image
  bottomrightX,bottomrightY); // location to place the bottomright of the image

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)