Hit test for drawable objects

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
swami
Posts: 5
Joined: 2010-10-05T10:44:07-07:00
Authentication code: 8675308

Hit test for drawable objects

Post by swami »

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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Hit test for drawable objects

Post by anthony »

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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
swami
Posts: 5
Joined: 2010-10-05T10:44:07-07:00
Authentication code: 8675308

Re: Hit test for drawable objects

Post by swami »

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
Post Reply