Zoom and View-Rotation corrections RFC

Summary: Please tell me I’m not crazy ;-). If you zoom in, the brush should look/act the same. If you zoom out, the brush should look/act the same. If you rotate the canvas, the brush should look/act the same.

https://github.com/briend/libmypaint/tree/view-zoom
https://github.com/briend/mypaint/tree/view-zoom

related to issue

These branches add two new inputs to feed view data from mypaint gui into the libmypaint brush engine. This is a major change because it affects both the brush engine and the GUI and the data model itself.

Backstory:
Starting with ZOOM:
Imagine trying to make a brush that mimics a dip pen. One thing about dip pens is that if you move your hand very quickly, you are likely to create splatter. So in mypaint you can add Jitter to mimic this. I have good results using random to define the jitter, but suppress it with large negative low speed values and then UN-suppress it once speed values get higher.

So once you have a brush like this working, it is unfortunately tuned to a certain hand speed at whatever resolution you happened to be designing the brush at. That is, if you zoom in, mypaint thinks your hand is moving very slowly-- you’ll never get any splatter. Likewise, if you zoom out, mypaint will think your hand is moving ridiculously fast, and you’ll get nothing BUT splatters no matter how slowly you move the brush. Basically, speed is not very useful right now for brushes.

So it becomes clear that the brush engine either shouldn’t be trying to figure out speed, and the logic should be moved to the mypaint GUI (yuck!)- OR, the zoom level from the GUI needs to be pushed over along with the other values like X, Y, pressure, etc. So I chose the latter, I pushed the zoom level (50%, 100%, etc) to the brush engine and then modified the formula for speed to take zoom into account. I also removed the way speed was influenced by brush size- that seemed counter-intuitive and I can only speculate as to why that was added. I suspect someone noticed this speed/zoom issue and fixed it somewhat by making big brushes move slower and vice verse-- which kinda works assuming that if you zoom out you will also likely increase your brush radius.

That’s all on zoom. The other issue is view rotation. Artists often rotate their canvas or piece of paper in front of them in order to get a better stroke with their drawing hand, or maybe other reasons as well. So mypaint GUI rotates the view, but the underlying brush engine doesn’t know anything about this. This is fine until you use brush settings that are relative to your body and/or tablet, like Direction and Ascension.

For instance, in real life if you rotate a canvas on an easel, paint will drip “down” the canvas. It doesn’t matter how you rotate the canvas, gravity is always “down”. However, in mypaint, the paint will drip left, right, up, etc- the brush engine has no idea that you rotated the canvas 90 degrees, etc. I’m thinking of @AnTi X/Y offset patch and a dripping brush that offsets in the Y direction-- these brushes do not work as you’d expect once you introduce rotation.

So, I’ve added viewrotation as an input just like zoom, and I’ve corrected Ascension and Direction to account for the rotated angle. Any other direction-related inputs that might be added will also need correction, so this is a bit of a domino-effect. @AnTi Direction360, and Offset and maybe others.

Ultimately I am scratching my own itch here- I want to make a very realistic dip pen and/or fountain pen (with railroading, splatter, etc) that works even when zooming in and out and when rotating the canvas. I can’t see why these ideas and changes would conflict with anyone else’s intentions for MyPaint, or even break any existing brushes. I think many people just haven’t pushed the brush engine into these territories where these underlying issues become obvious-- or maybe a lot of people never zoom in or out, and never rotate the canvas, these are all possible. Thanks for reading!!

1 Like

This is awesome, and I don’t think you’re crazy! I have some custom brushes which use speed-dependent jitter, but you’re absolutely right, they don’t behave as expected at different zoom levels. Will definitely check out these changes/fixes.

Thanks! I’ve updated the branches so now speed, ascension, direction, and dab angle are consistent across zoom and canvas rotations. Let me know if you notice any problems!