don-tnowe / godot-sprite-painter

Image editor right inside Godot 4.
MIT License
79 stars 8 forks source link

Update tool_brush.gd add min brush size #20

Closed DearFox closed 4 months ago

DearFox commented 4 months ago

Fixes strange brush behavior when drawing from a graphics tablet when the pressure on the stylus is low enough that the actual brush size is less than 1 pixel

We're talking about this strange brush behavior: 4f03ca066d5710a2

Adds a new setting for the brush and eraser tools: изображение

Known "bugs": "Min Size" - not limited by the maximum threshold equal to "Size" It follows from this that if “Min Size” is greater than “Size”, then “Min Size” will have priority.

don-tnowe commented 4 months ago

LGTM! There's also other brush-like tools, I'll edit this after merge.

Do you think it's worth changing this to make width go from minsize at minimum pressure to size at maximum, linearly via lerp(min, max, pressure), instead of all pressure levels below minimum giving the minimum width? This could also "fix" the unconstrained minsize issue.

DearFox commented 4 months ago

LGTM! There's also other brush-like tools, I'll edit this after merge.

Do you think it's worth changing this to make width go from minsize at minimum pressure to size at maximum, linearly via lerp(min, max, pressure), instead of all pressure levels below minimum giving the minimum width? This could also "fix" the unconstrained minsize issue.

Sounds like a good idea. To be honest my implementation is a bit rough

DearFox commented 4 months ago

I was offered a replacement var radius = max((brushsize * 0.5) * (pressure if pen_flags[0] else 1.0),(brushminsize * 0.5)) on var radius = remap(((brushsize * 0.5) * (pressure if pen_flags[0] else 1.0)), 0.0, (brushsize * 0.5), (brushminsize * 0.5), (brushsize * 0.5)) In the paint function

This should solve the unused push in my previous implementation.

don-tnowe commented 4 months ago

Look overengineered, but good. Thank you!

don-tnowe commented 4 months ago

Interesting behaviour:

gif2