[quote=334873:@Dave S]I understand… and totally disagree with mining the pixels of a picture to determine the mathematical relationship between a curve and a point (mouse)…
and the movie proves and disproves nothing… as you didn’t indicate the behind the scenes
my Snapdragon draws things that look exactly like what you showed… and basically it moves ONE point (which is already known)[/quote]
Cool, you’re welcome to disagree if you wish, whatever method you choose is up to you
The mathematical relationship between a curve and a point (mouse) isn’t what Edwin wanted, he doesn’t want to know how far down the line he’s clicked or which segment he’s clicked on, he just wants to know what curve is clicked on when he pressed the mouse.
Here’s a “proof of concept” that took less than 60 minutes to put together (never used half of this stuff before, so it took longer that it should have).
https://www.dropbox.com/s/5qdd702bpnbfstd/BezierPick.xojo_binary_project?dl=1
Using this method will work for any shape you throw at it for up to 24bit’s worth of unique items (approx 16.7m), I’m guessing that is plenty.
I’m not saying its the best way or the most memory efficient, but its a totally valid and usable method of performing what Edwin required from his original post.
Now here’s the rub:
Its faster than iterating through the curves, it wont slow down the more curves you have on the image and it’ll work for any type or number of segments on the curve, it’ll even work for other types of objects! extra fancy
The only overhead is that you double your picture allocation for the “hit mask” to check against and you draw twice (once to actual and once to the hit mask)
So, back to the original question you had about the concept:
Lets say there’s 10 curves in close proximity and you click slightly off the line, all I have to do is:
Mask.Graphics.Pixel(x, y)
Vs
worst case 5000 iterations of a loop (500 iterations * 10 curves to check)