Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

76-ish pixels per Unit... 0.O ??? (API and Hex Grids)

1410140958

Edited 1410142085
I discovered something Strange while writing code in the API for weapon ranges: Roll 20 says that there are always 70 pixels per Unit... but there aren't. First of all: I am using a vertical hex grid for my Campaign, and my tokens are set to snap to the hex bounds when moved. Therefore, the exact 'top' and 'left' properties are being set automatically by the UI, not my scripts. I have it set to 1 Unit = 5 feet. I am using the standard distance formula to find the raw distance between two tokens in pixels, which I then convert to feet. The Problem is, that it's not coming out to be 1 Unit = 70 pixels, but rather some non-integer approximately equal to 76 pixels. And worse, the distance between two hexes varies, based on which "direction" one is from the other. Has anyone else observed this? Any explanations?
1410141947
Gid
Roll20 Team
It's only 70 pixels per unit for square grids. The hex grid is mathematically drawn so the pixel unit is approximations. UI Element Pixel Width Pixel Height Grid Square 70px 70px Hex Unit (Vertical)* ~75px ~88px Hex Unit (Horizontal)* ~94px ~81px <a href="https://wiki.roll20.net/Image_Best_Practices_for_R" rel="nofollow">https://wiki.roll20.net/Image_Best_Practices_for_R</a>...
Oh! Wow. Thanks! ^_^ I think this will help. Do you happen to know how they draw the grid, or calculate the snap-to properties of it?
1410142623

Edited 1410142675
OR - is there an API function call that comes with Roll20 that I can just pass the two Token references to, and it can return distance in units? Just the way the Rangefinder tool does, but, for my API...
1410147977

Edited 1410147985
Gid
Roll20 Team
Let me move this to the API forum for you. I'm really out of my depth when it comes to fiddling with the API, but over in that forum you'll get more eyes who might be able to help out.
OK thank you Kristin! &lt;3