OS-Bot-COLOR icon indicating copy to clipboard operation
OS-Bot-COLOR copied to clipboard

Added Geometry Methods!

Open hewentto opened this issue 2 years ago • 6 comments
trafficstars

Fixes OSR-29 Fixes 119

Added the following methods Rectangle.scale() RuneliteObject.scale() Rectangle.get_center_left RuneliteObject.distance_from_rect_left RuneliteObject.distance_from_top_left()

hewentto avatar Apr 29 '23 01:04 hewentto

Examples https://imgur.com/a/ijxCs8Q

hewentto avatar Apr 29 '23 01:04 hewentto

This is now done, one point to note is the RuneliteObject loses its "shape" with the scaling method, now instead of axis containing all the points within it's bounding color-box, it has all the points within its new corners. This can be revisited another time but without sucking all the processing and taking seconds this was the fastest way. When scaling it's a given that we lose accuracy anyways, but there could be a better way.

hewentto avatar Apr 29 '23 14:04 hewentto

Another alternative and quicker processing is to use the check for axis in the random_point() method only check if a rectangle is not scaled. Maybe when we scale a rectangle set a boolean to true

hewentto avatar Apr 29 '23 18:04 hewentto

#119

hewentto avatar Apr 30 '23 06:04 hewentto

I added some additional methods for sorting based on arbitrary points. Haven't had time to review the rest but will hopefully get at it this week.

kelltom avatar Apr 30 '23 22:04 kelltom

I think the solution for the random_point thing will be to have a parameter to toggle whether we should only return a random point that exists within the outline bounds (axis). The is_scaled flag idea you bring up is also good... That might make more sense -- people are going to scale them literally to increase the click box.

With all that said, since I added that sort key method that allows any point as input, should we get rid of the other hardcoded ones? Probably not necessary to have them, as sorting code is typically only written once, so it's not like it's added work to add the extra parameter. That way, we can also implement sorting for tile-based movement based on the direction the player has to travel (and thus, any point along the edges of the game view). This would result in possibly more accurate results.

And last, I think I might add some translate methods as well, so you can shift a rectangle a bit. In this case, I think the random_point should still return a point that is truly within the shape; the main use case being that we can shift a rectangle toward the position of the mouse slightly to make clicks gravitate closer to the edge of the object where the mouse is coming from. Basically a realism thing. I think I saw that translation was kinda possible in your scale method, but if scaling is going to set that "is_scaled" flag, then maybe it can be separate -- idk just spitballing.

~~Will look at this with fresh eyes tomorrow~~ <-- this was a lie

kelltom avatar May 01 '23 03:05 kelltom