mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:27:35 +00:00
PixelPaint: Add Polygonal Select Tool
Polygonal selection tool allows for the drawing of any arbitrary polygonal shape. It tracks clicked points in a vector, upon double clicking we finalize the polygon and generate the selection mask. The user can press the escape key during selection to cancel. The mask is generated as follows: - First we calculate the size of the bounding rect needed to hold the polygon - We add 2 pixels to height/width to allow us a 1 pixel border, the polygon will be centered in this bitmap - Draw the polygon into the bitmap via Gfx::Painter, making sure to connect final polygon point to the first to ensure an enclosed shape - Generate a selection mask the size of the bitmap, with all pixels initially selected - Perform a flood fill from (0,0) which is guaranteed to be outside the polygon - For every pixel reached by the flood fill, we clear the selected pixel from the selection mask - Finally we merge the selection mask like other selection tools.
This commit is contained in:
parent
20f6485311
commit
038a833f0c
5 changed files with 269 additions and 0 deletions
|
@ -62,6 +62,7 @@ set(SOURCES
|
|||
Tools/MoveTool.cpp
|
||||
Tools/PenTool.cpp
|
||||
Tools/PickerTool.cpp
|
||||
Tools/PolygonalSelectTool.cpp
|
||||
Tools/RectangleSelectTool.cpp
|
||||
Tools/RectangleTool.cpp
|
||||
Tools/SprayTool.cpp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue