Hello. This question is about the Magick++ API on Windows.
In my C++ program, I have instantiated a few renderable Drawable objects. Is there any way for me to test whether a given coordinate (such as the mouse cursor location) is:
1. Upon (or near) the drawable object boundary (stroke)? For example, on the stroke of a circle, or an ellipse.
2. Within the closed object shape, such as within a circle?
3. Both the above, AFTER an affine transform has been applied to the drawable object?
Will appreciate any guidance on this.
Thanks in advance.
SN
Hit test for drawable objects
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Hit test for drawable objects
not in an easy straight forward way.
Simpliest is probably create a scratch canvas. Draw to it with the right colors and see if that pixel's color changed.
NOTE -draw does not understand virtual canvas (unless annotating text) so you can't create a 1 pixel image with a virtual offset to texting. So the canvas will need to be at least the pixel posiotion +1 in size.
Also note that -draw uses 'pixel coodinates' that means '0,0' means the center of the pixel in the top left corner. It does not mean the actual top and left edges of the image. This however is usally more important for matching 'draw' with the exact center o fthe image, or wth 'distort' coordinates.
See Image Coodinates vs Pixel Coordinates. (in Distorting Images)
Simpliest is probably create a scratch canvas. Draw to it with the right colors and see if that pixel's color changed.
NOTE -draw does not understand virtual canvas (unless annotating text) so you can't create a 1 pixel image with a virtual offset to texting. So the canvas will need to be at least the pixel posiotion +1 in size.
Also note that -draw uses 'pixel coodinates' that means '0,0' means the center of the pixel in the top left corner. It does not mean the actual top and left edges of the image. This however is usally more important for matching 'draw' with the exact center o fthe image, or wth 'distort' coordinates.
See Image Coodinates vs Pixel Coordinates. (in Distorting Images)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Hit test for drawable objects
Hi Anthony,
Thanks for your response and suggestions. Will try them out.
(My apologies for the late acknowledgment - didn't get around to checking this board in the last so many days.)
Regards,
Swami
Thanks for your response and suggestions. Will try them out.
(My apologies for the late acknowledgment - didn't get around to checking this board in the last so many days.)
Regards,
Swami