Two years ago, I created Motif.js to easily generate patterns in SVG or Canvas. It specifically includes a size parameter to handle ordinal textures, like those in your example. See my plot example very similar to the one you made : https://observablehq.com/@ateliercartographie/motif#cell-4969