exyte / Macaw

Powerful and easy-to-use vector graphics Swift library with SVG support
MIT License
6.02k stars 556 forks source link

Inverted node displayed when manually drawing #757

Open mcbauer08 opened 3 years ago

mcbauer08 commented 3 years ago

Hi. When drawing paths manually with the mouse and using findNode() in mouseDragged() or touchesMoved() override methods in the ViewController the node will display in the background with whatever stroke and color I am drawing with but also be inverted. I tried to follow the logic in the findNode() source code maze of why that inverted node flashes on screen but I couldn't find a good answer. It's got to be some drawing context that's capturing my stroke color. I tried to save my graphics state in my MacawView draw() method encompassing my setting the stroke color and drawing the paths then restoring it but that didn't work. I have tried drawing on a plain NSView subview and also setting the color to clear after stroking the paths in draw(). Do you have any ideas how I might avoid the node flashing on screen like this?

Thank you.

mcbauer08 commented 3 years ago

A little background into what I'm trying to do: I am attempting to draw across nodes and detect them as soon as I cross from node to node. findNode() works well in mouseDragged() but gives a visual error. If there is a better way using onPan() or onTouchesMoved() please let me know. I am unable to find code showing this and all my efforts came up empty. I can get onTap() to work but dragging across them doesn't seem to.