Embed a free-form drawing in a drawing application

I would like to think about how to implement free-form drawing in a drawing application. Given that the command object will include a click down, arbitrary drag and drop, how will it be necessarily saved in the command and drawn in the context of the bitmap?

First, will the data just correspond to each pixel coordinate in the mousemove command placed on a large list? I cannot come up with any other obvious approach, as the user probably does not draw long, completely straight lines that can be optimized.

Will its drawing essentially print solid circles (radius, which is the width of the pen), at each coordinate specified in the mouse move, and interpolate between them if the movement is far enough?

Update: An explanation of what I had in mind when I asked how the data would be stored. I talked about how the data in the command object would look, and thought it would be a list of β€œmove-to” pixel coordinates to represent the action. I did not mean the representation of the data in the bitmap that was drawn.

+4
source share
1 answer

I think it depends on whether you want to cancel functionality. If not, you do not need to save the list of commands, you can just update the bitmap in the MouseMove handler.

If you want to cancel, then you may want to save the commands (in this case, the list of coordinates moved by the mouse during drawing, i.e. when you click the mouse button) is one way to do this. You will also need to keep track of settings (e.g., pen radius, color, etc.).

Alternatively, you can simply save several copies of the bitmap after the completion of each command (although this would use more memory for large bitmaps).

0
source

All Articles