javascript - Scaling mouse co-ordintates for different resolutions -


i working on heatmaps , have different resolutions [1920x953], [953x502]. gathering points resolutions , want draw heatmap on [1280x768]. getting problems scaling not working properly.

i have got mouse co-ordinates(1160,35) in [1920x953], (704,35) in [953x502] , want draw these points on [1280x768] resolutions. so, points must scaled up/down regarding target resolution. have used these formulas, not getting correct value. way, (839, 35) value of [1280x768].

targetscreenpoint = (capturedscreenpoint/captured screen resolution) * target screen resolution   tsp = (1160/1920) * 1280 = 773 

and

target screen point = (target screen resolution - captured screen resolution)/2 + captured screen point   tsp = (1280 - 1920)/2 + 1160 = 840   

the first 1 method giving wrong value 773. second 1 giving correct value 840.

but want use generic formula scaling. please in regard. thanks!


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -