-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spaces between circles in GDPaint #846
Comments
This is because Bresenham's line algorithm needs to be implemented in the demo, placing a circle every pixel between the last two reported input events (or perhaps every 2 pixels to improve performance, at least with larger circle sizes). Feel free to open a pull request for this 🙂 |
Something like Line2D (points between mouse movement)? |
No, the Bresenham algorithm is something you can implement with relative ease in GDScript. No high-level nodes should be used here. See this implementation in C++ from Godot itself: https://github.com/godotengine/godot/blob/0c27edf3d971bd3accffbaee5c57da33d0549284/core/math/geometry_2d.h#L426-L462 The C++ implementation isn't exposed to the scripting API, but this could likely be done in a future 4.x release. |
Why something like this is bad method (it works)?
|
Can you show a video/GIF of drawing lines with fast mouse motion with this method? While not ideal (and not applicable to all situations), it might be good enough for this particular demo. |
Nagranie.z.ekranu.2023-02-18.o.00.14.32.mov |
@michaldev Looks good! Please open a pull request 🙂 |
I tested this solution for a longer time and I think it's not very good - when there are more drawn lines, significant delays appear between the mouse cursor and the currently drawn line. And technically, I think that a lot of unnecessary objects are created. |
The way the demo is designed allows for more flexibility, but it was never intended to be as fast as possible. It's a proof of concept after all 🙂 |
|
Not familiar with this demo, but I wonder why bresenham's line algorithm would be so useful here? I mean, I guess it would work eventually, but it's a circular brush. Bresenham only gives you a series of jagged positions for a single-pixel line, allocating a long array as well. Using it repeatedly to fill a thicker line one by one (especially as shown earlier) doesn't seem great for performance when the GPU can draw the same thing with a few polygons. Using it to draw many circles every 2 pixels wouldn't be good either. Assuming this is painting on a Viewport, #846 (comment) would work better, although for opaque colors only. It won't do well with transparent, and wont scale well if every line and circular joint is drawn as separate calls. I think the algorithm Line2D uses would work better out of the box (draws all at once, with circular joints and no overlaps with transparent colors), but since it wasn't used in Regarding slowdown when many things are drawn, it can be brought down to zero by "printing" what's been drawn so far into a background image. Usually can be done if the canvas is a Viewport that doesn't clear. But again, maybe it's not the goal to have many fancy and optimized features in the demo. |
Hi. Why in your demo I have spaces between circles? How can i fix it?
Nagranie.z.ekranu.2023-02-17.o.21.02.20.mov
The text was updated successfully, but these errors were encountered: