acamposuribe / p5.brush

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js
https://p5-brush.cargo.site/
MIT License
442 stars 22 forks source link

Suggestion: ability to make "smooth continuous line" brushes #32

Open gwhitney opened 2 weeks ago

gwhitney commented 2 weeks ago

I have been using p5.brush to add hatching to some bar charts. It looks very nice, but as far as I can tell, all possible brushes have some level of variability/splotchiness to their strokes. Sometimes you may just want a nice smooth line drawn along the path of the brush. The closest I managed to get was

brush.add('line', {
            type: 'standard',
            weight: 1,
            vibration: 0,
            definition: 1,
            quality: 255,
            opacity: 255,
            spacing: 1,
            blend: false,
            pressure: {type: 'standard', curve: [1, 1], min_max: [1, 1]},
        })

but if I end up re-drawing some hatching using this brush when I update frames, the hatching still seems to "shimmer" a bit. I can make it deterministic by re-setting the seed each time, but frankly in some cases I would rather just have boring 'ol straight lines ;-)

P.S. I have attached an updated TypeScript definitions file for this lovely module. Anyone wanting to use p5.brush in a TypeScript setting will need something like this. You might want to just ship one in the dist folder of your library on npm. You are welcome to use this in any way that would be helpful.

p5.brush.d.ts

acamposuribe commented 1 day ago

Hi @gwhitney

Thank you for the TypeScript definitions. To be honest, I've never used TypeScript, but I would check these if I ever decide to update p5.brush with it.

Regarding your request, I think what you are intending to do can be much more easily done with custom code, no need to import the whole library. I could help you define a hatching algorithm if you want, or you can reuse that part of the code without the natural brush effect. p5.brush draws lines by adding points together, which doesn't make sense if you just want normal boring straight lines!

Let me know if you need help!

gwhitney commented 15 hours ago

Regarding your request, I think what you are intending to do can be much more easily done with custom code, no need to import the whole library. I could help you define a hatching algorithm if you want, or you can reuse that part of the code without the natural brush effect. p5.brush draws lines by adding points together, which doesn't make sense if you just want normal boring straight lines!

I mean, there are numerous sketches out there that do hashing, but (perhaps surprisingly) the only npm-downloadable add-on package for p5 that offers a hatching fill, that we could find, was yours. We're not really interested in maintaining our own hatching function -- we just want one we can download and use. So you could easily fill the gap by adding "boring straight lines" to your package -- I do think they would round it out in a way, and could still be valuable with the other effects. Or maybe you know of another existing package for "boring" hatching? Anyhow, these are just suggestions for you. Feel free to use, and by the same token, also feel free to close this issue as wontfix.