williamngan / pts

A library for visualization and creative-coding
https://ptsjs.org
Apache License 2.0
5.19k stars 182 forks source link

Patterns #166

Open camilleroux opened 2 years ago

camilleroux commented 2 years ago

Hi,

Is there a way to create patterns like in SVG? Can I do it at least in a SVGSpace?

williamngan commented 2 years ago

Thanks @camilleroux - that would be a great feature to add to Pts. I need to think about how to make it simple.

For now, you can try the standard API from canvas, eg, form.ctx.createPattern(...)

See MDN docs: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createPattern

williamngan commented 2 years ago

Hi again @camilleroux! Took me a while but I finished it -- the Img class now supports both static and dynamic patterns in Canvas. Take a look at the guide here and let me know if you have feedback. Thanks.