Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate PointF[] pointFs #2

Closed
siddhpuraamitr opened this issue Jun 22, 2017 · 4 comments
Closed

How to calculate PointF[] pointFs #2

siddhpuraamitr opened this issue Jun 22, 2017 · 4 comments

Comments

@siddhpuraamitr
Copy link

siddhpuraamitr commented Jun 22, 2017

in example i got points like X, Y like below

private PointF[] pointFs = new PointF[]{
// new PointF(0.55413014f, 0.8852321f),
// new PointF(0.47312737f, 0.2281924f),
// new PointF(0.7258657f, 0.46690002f),
// new PointF(0.4931545f, 0.573822f),
// new PointF(0.51643884f, 0.45194212f),
// new PointF(0.4382141f, 0.29778966f),
// new PointF(0.29861376f, 0.36735255f),
// new PointF(0.5429275f, 0.30569845f),
// new PointF(0.3812865f, 0.6557617f),
// new PointF(0.4198726f, 0.3800899f),
// new PointF(0.55254054f, 0.0431957f)
// };

by using about points I am getting all images

but in my case I have below x, y of Points

//            120.0, 140.0
//            120.0, 176.22382
//            120.0, 180.0
//            120.0, 216.58829
//            120.0, 220.0
//            120.0, 258.6094
//            120.0, 260.0
//            120.0, 299.88354

I have used above points but I did not get any image on ImageMap

will you please help me how can i convert my points to your example points..

@Pernifloss
Copy link
Owner

hello siddhpuraamitr. i'm glad you are interested in this library.
Imagemap work with 'ratio', if you want to position a point on an image you have to calculate the coordinate so the x and y points ar beetween 0 and 1.

PointF(0.5f, 0.5f) will always get you at the center of your image. PointF(0f, 1f)will get you the bottom left corner, PointF(1f, 0f)the top right etc...

In your case if you have a 500x400 background image and want to positionate a clickable image at 120.0, 140.0 , you have to calculate x and y so they are beetween 0 and 1.
120.0 become 120.0/500 => 0.24f
140.0 become 140.0/400 => 0.35f

the formula is pretyty simple:

x = yourX / backgroundWidth;
y = yourY / bachgroundHeight;

hope this will help.

Pernifloss

@siddhpuraamitr
Copy link
Author

Hi sir,

Thank you so much for your nice suggestion,

Sir, I have suggested what you have told me and still find issue, because of in Github I can not attach image so I have posted question in below link

https://stackoverflow.com/questions/44819830/correct-points-value-in-imagemap

Please check and help me

Thank you so much from
Amit Siddhpura

@AchmadFadillah
Copy link

I want to ask is there another way to get PointF automatically from any image?

@Pernifloss
Copy link
Owner

Hello, @AchmadFadillah i don't understand how you could "get PointF automatically", the purpose of this librabry is to have clickable images on top of a main background image. The PointF returned in the adapter define where to put a given small image. (I'm closing this issue since it from 2017. please open a new one is you need)

Pernifloss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants