Very simple interpolated drawing code

I just found this:

thank you for writing it !

We can also try Blend2d. I think he is using plain C, so using the Blend2D C API should be easy. The only additional step is copying from a Blend2D surface to a GtkDrawingArea. For that step we had a forum discussion maybe one year ago, it is not that difficult. Unfortunately, when using other languages than C or C++, then we have to create the bindings to Blend2D first.

The GitHub - jpbruyere/vkvg: Vulkan 2D graphics library may be also an option, seems the author is still working on it.

@MCarthy: I hope you have answered your question at the cairo mailing list from some days ago now yourself? As you seems to have solved the issue. The reason that no one other answered is not only that cairo is orphaned as you said, but more that you gave not enough context – it was impossible to guess your real issue from your message. And I think you send your mail as HTML, which may be not really welcome. One remark to your tool: For me it is a bit strange that you draw single points with your scribble app. Cairo is a vector lib, so joining the points with lines would make more sense for me. Or, you may use just a raster/bitmap surface.

My code was missing a crucial gtk_widget_queue_draw() so the re-initialization and clearing of the drawing area didn’t happen. The drawing area was initialized correctly when things were first set up. However, my “clear” button simply didn’t work. All is now good. :smile:

I just want to draw a basic filled circle (dot), and Cairo seemed to be the simplest way forward despite it being a vector library. Now I can gain yet more facility using GtkGLArea though it’s a bit of overkill. It is possible that Cairo is fast enough but that the speed of the main Gtk event loop “misses” stylus moves. Consequently interpolating/joining sequential stylus positions is necessary. The results vary depending on the speed of the machine that I test things on. A cheap x86 tablet with a Celeron N4120 doesn’t work as well as an i7-1165G7 – no surprise there.

1 Like

My scribble_email code now uses cairo_draw_to() which works well enough by linearly interpolating between drawn points: https://github.com/CliveMcCarthy/scribble_email

Thank you guys for your help.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.