Page 1 of 1

Hit test for drawable objects

Posted: 2010-10-21T08:08:27-07:00
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

Re: Hit test for drawable objects

Posted: 2010-10-21T22:09:03-07:00
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)

Re: Hit test for drawable objects

Posted: 2010-11-03T06:48:10-07:00
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