[android-developers] Re: how to create irregular polygon and handle events within its boundary

2010-12-28 Thread ip332
Processing a click in side a polygon can be difficult task.
There is another solution based on a bitmap where each clickable shape
has its own color.
I have described it in another thread, named "Overlay to make parts of
image clickable"
Let me know if something is not clear.

On Dec 27, 11:51 am, Achie  wrote:
> How can we create polygons with shapes other than the normal regular
> rectangle/circle etc? I need to create a image with boundaries and let
> users click within the image. Then I need to highlight the image.
>
> I also need to highlight the image only when the user clicks within
> the boundaries of the shape.
> How can I do this in android?
>
> Thank you.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: how to create irregular polygon and handle events within its boundary

2010-12-27 Thread Frank Weiss
Vectoring parts of a photographic image is going to be more difficult than
the example I lnked.

I think you'l have to zoom the vertices in the polygon yourself, but you
might try using some drawing transformation methods - you may have to dig
deeper into OpenGL.

Now that you've given more problem details, maybe polygons isn't the only
approach. Are you trying to map the touch coordinates to a certain shade in
the man's arm, or to a particlar part of the arm? In the latter case, it
might work out to just use points for the center of each part (bicep,
tricep, elbow, etc.) and use an algorithm based on the distances of the
centers to the touch point. This may involve additional geometry skills,
such as dividing an area into regions based on such centroids. However,
sometimes looking at a problem from a different perwspective leads to a
better solution.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: how to create irregular polygon and handle events within its boundary

2010-12-27 Thread Achie
That is very helpful,

I will start looking into getting a verices list for my images.

Is it possible to extend this so that I can use my own images Instead
of using some fixed color in the shape? [eg I have an image of man's
arm and it has shades in it. So can I use it as the object that is
being displayed?]
And is it also possible to zoom in/out if I take this approach or do i
have to consider doing something else? I am asking this since I am
assuming that the vertices that I obtain will limit me use some
standard px sizes in my Layout.

Thanks again Frank.

On Dec 27, 3:04 pm, Frank Weiss  wrote:
> I suppose it seemed simple for me since I'm done it with AWT before.
> Basically, you build up a Polygon object with vertices. You pass it to the
> Graphics.draw method to display it (or not if you want an invisible hit test
> layer over the image). You intercept click or touch events and use the
> Polygon's inside() or contains() method to do the hit test.
>
> Depending on the complexity and display size of the image, you may run into
> some hit test accuracy issues due to the touch UI.
>
> If you have the original artwork in Adobe Illustrator, you ought to be able
> to get a vertex list therefrom. If not, google for a raster-to-vector tool
> of your choice, for 
> example:http://freegeographytools.com/2007/converting-raster-area-images-into...

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: how to create irregular polygon and handle events within its boundary

2010-12-27 Thread Frank Weiss
I suppose it seemed simple for me since I'm done it with AWT before.
Basically, you build up a Polygon object with vertices. You pass it to the
Graphics.draw method to display it (or not if you want an invisible hit test
layer over the image). You intercept click or touch events and use the
Polygon's inside() or contains() method to do the hit test.

Depending on the complexity and display size of the image, you may run into
some hit test accuracy issues due to the touch UI.

If you have the original artwork in Adobe Illustrator, you ought to be able
to get a vertex list therefrom. If not, google for a raster-to-vector tool
of your choice, for example:
http://freegeographytools.com/2007/converting-raster-area-images-into-polygon-shapefiles

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: how to create irregular polygon and handle events within its boundary

2010-12-27 Thread Achie

> OK, so how hard was it to google android polygon?
hmm its harder than just assuming that I did not do the same. I have
been looking around for that since a couple of days. May be I am
searching with the wrong terms.
Still thank you for the reply. The results does not pull up what I am
looking for. But your suggestion did show me something helpful I can
use later. [ie to detect if a point lies inside a polygon]

No I do not have a Vertices list. I have an image that has the shape.
It is a human body with parts[head, arms, legs etc]. That is why I was
looking for some hint of where I might have to start looking. I need
to somehow convert this into a vertices list or was actually wondering
if android has any builtin classes that I can take advantage of.

Thanks.

On Dec 27, 2:08 pm, Frank Weiss  wrote:
> OK, so how hard was it to google android polygon?
>
> The tougher question may be do you already have the polygon as a vertex list
> or do you just have an image that has a polygon?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en