Inside the squares I place individual images.
In two squares I am trying to use SVG images so that they take a random color from the URL constant, but they do not color.
I haven’t found any reference about SVGs. This is my code.
This is my code. Why doesn’t work?
Try looking up methods in the reference or examples on p5js.org. You will see that this is no “loadsvg”. However, I see why this was hard – SVG isn’t listed in the reference, either. What you want is loadImage().
Here is an example of loading an svg:
However: some svg images do not work. p5.js loadImages has only partial SVG support (the SVG spec is enormous, with tons of features, some of which aren’t supported).
If you have a complex SVG that cannot be viewed, you can try making a simpler version of it / recreating it, or you can try using the HTML DOM to display the SVG in the browser as a separate layer on top of the canvas, not draw it on the canvas. But it sounds like you want to draw it on the canvas.
I didn’t understand this part of your question. The rest and your code example sounds like you are having a hard time loading your SVG images – they don’t work – but this sounds like you can display them and are trying to tint them? Or they are line drawings and you want to change the line color? More information needed, and a code example, not a fragment.