On 20/12/2012 15:15, Dean S. Jones wrote:
Of course, as Umit says, there are other FREE Frameworks that have figured it
out, like
Lienzo, that take care of it all for you, http://www.emitrom.com/lienzo
Hey, I didn't know this one! Looks cool. Thanks for sharing.
(Even if I discovered you are
I'm creating some kind of drawings/flowchart/UML-diagram like tool with GWT
Canvas (Java).
For hit-detection of my drawings I could imagine 3 different strategies,
but I do not know which would work best for my goal.
- Just keep track of all Shape coordinates and iterate all objects on
First option is definitely best, but you need to expand it slightly:
Use a bounding box around every shape, so you can do an O(1) check if the
click is inside the bounding box (click.x box.left, click.x box.right,
etc)
If the click is inside the bounding box, then you can run normal edge
All methods are viable.
I know that the color based hit detection is widely used and supposed to be
quite efficient.
There are a couple of stackoverflow threads about that:
http://stackoverflow.com/questions/31158/resources-of-techniques-use-for-collision-detection-in-2d
I had posted, why reason it was deleted?
On Thursday, December 20, 2012 6:14:43 AM UTC-5, membersound wrote:
I'm creating some kind of drawings/flowchart/UML-diagram like tool with
GWT Canvas (Java).
For hit-detection of my drawings I could imagine 3 different strategies,
but I do not
In Lienzo, we opted for a Color Map approach. Detecting bounding boxes as
previously suggested in the thread is not a trivial task, more so for non
geometrical shapes.
http://wiki.emitrom.com/wiki/index.php/Picking
Lienzo is only 4 months old and already surpasses in functionality and
efficiency
A bounding box check isn't O(1), it's O(n) for n shapes, THEN you have to
run edge detection, and only then if all your shapes are Polygons. The
issue with bounding boxes is that, in all but the most trivial cases, they
are expensive to compute. If you add in any Affine Transforms ( rotate,
The check itself is obviously O(1) per check, as opposed to O(num of lines)
for his original proposal (iterate all shape components) - and the 'etc'
should have kind of implied to you there were 4 checks and not 2...
Also, he is not making a 3d engine here and is very unlikely to need
As long as the shapes are simple, in a UML diagram you have mostly boxes,
some arrows, and text, AABB bounding boxes are easy to compute, as long as
your not worrying about overlapping shapes which could be hollow:, i.e. you
have a large rectangle with a small rectangle inside, the large
one is
Ah awesome, I didn't realize you were behind Lienzo. :)
You should have mentioned - it came across that your advice to him was an
impossibly difficult solution considering his question. As you say, using
Lienzo for this is definitely the right answer!
However regarding the inner/outer boxes
I was taking a larger view, in the sense of the thread itself, ( over and
above his question ) of the practicalities and pitfalls of hit detection in
Canvas as a whole. Section 4.8.11.2.15 of the Canvas specification mentions
Hit Regions, sadly, they are for bitmaps, not shapes, and do not seem
Yeah something else that I have been silently playing with is a scrollable
layer :) that would also help in this case.
I think it's safe to say that the guys behind Lienzo are all well rounded
engineers that have been around the block. Biggest issue is as Dean said,
time constraints since we all
Use of a bounding box over every shape isn't O(1), it's O(n) for n shapes,
but then you still have to do a real' hit detection, which is
mathematically much more interesting for things like bezier and quadratic
curves, etc, unless you decompose the curves to polylines, this isn't all
that fun.
13 matches
Mail list logo