在 P5.js 中有没有办法加载和剪辑带有圆形边框的图像?
Is there a way to load and clip an image with a round border in P5.js?
加载和裁剪图像可以在 fabricJS 中使用本机 Canvas 方法完成,但在 P5.js 中?
绘制圆角边框的唯一单行方法是使用指定圆角半径的参数调用 rect()
函数。您或许可以将其绘制在图像之上以实现您正在寻找的效果。
如果没有,那么下一个最好的办法就是使用 createGraphics()
function to create a buffer. Draw your image to that buffer, then take the corners away from the buffer. Then you can draw the buffer to your canvas using the image()
函数,就像您将常规图像绘制到 canvas.
另一种选择是使用图像编辑器提前为图像添加角。
在 P5.js 中,如果您想将样式应用于图像,最好的解决方案是使用 p5 DOM Api。
使用 [createImage()][1];
,您可以使用动画样式。这里有些例子:
https://p5js.org/reference/#/p5.Element/style
加载和裁剪图像可以在 fabricJS 中使用本机 Canvas 方法完成,但在 P5.js 中?
绘制圆角边框的唯一单行方法是使用指定圆角半径的参数调用 rect()
函数。您或许可以将其绘制在图像之上以实现您正在寻找的效果。
如果没有,那么下一个最好的办法就是使用 createGraphics()
function to create a buffer. Draw your image to that buffer, then take the corners away from the buffer. Then you can draw the buffer to your canvas using the image()
函数,就像您将常规图像绘制到 canvas.
另一种选择是使用图像编辑器提前为图像添加角。
在 P5.js 中,如果您想将样式应用于图像,最好的解决方案是使用 p5 DOM Api。
使用 [createImage()][1];
,您可以使用动画样式。这里有些例子:
https://p5js.org/reference/#/p5.Element/style