I have to build a functionality very much similar to erase or pencil using (Square or Circle Tool) where the size of the Square(SIDES) and Circle(RADIUS) can be changed by the user so sides of square and the radius of the circle need to be changed. As the cursor moves around in the Drawing area.
Here is the image for your reference and better understanding
- I would like to draw a square or circle with the size selected by the user using dotted lines keeping cursor x,y as their(square) center points.
- I would like to add a small Icon similar to eraser in the image
PS: I have used GIMP erase tool to demonstrate the requirement. If I am not wrong even GIMP has been written using GTK
Have a look at
gtk3-demo, depending on the version you use).
There is a “Cursors” demo showing how to use custom pointers, and a “Paint” demo showing how to draw a square at cursor position.
Since it is for Gimp: can’t you use a regular brush, that can be circle or square (or any other shape) and can already be changed on-the-fly (pressure if using a stylus, keyboard shortcuts, or secondary mouse buttons or mouse wheel)?.
Hey @gwillems I am using gtkmm-3,24, on some search I found this https://github.com/GNOME/gtkmm/tree/gtkmm-3-2/demos but unable to find the cursor and the paint demo that you mentioned. Can you guide me where exactly I can find those examples?
I came across this Programming with gtkmm 3 can’t seem to find the examples you mentioned
I want to build a functionality similar to what GIMP has like erase and pencil into a custom application I am building. I am not actually using gimp anywhere in the custom application.
The source code of the demos is here:
It’s not gtkmm/C++ but gtk/C, but I hope you’ll get the idea.
If you use Linux, the
gtk3-demo tool should be installable (on Ubuntu it’s provided by the package “gtk-3-examples”), so you can play with it to see the actual result.